Python回溯指向不存在的文件

时间:2014-07-02 18:13:51

标签: python

我正在尝试运行setup.py脚本(mnemosyne)。脚本失败了,我很确定我知道如何解决问题,如果我只能找到要编辑的文件。问题是回溯指向一个不存在的文件:

  File "build/bdist.macosx-10.5-x86_64/egg/macholib/MachOGraph.py", line 49, in locate
    loader=loader.filename)
TypeError: dyld_find() got an unexpected keyword argument 'loader'

我认为应该是loader_path。问题是MachOGraph.py文件不存在 - 不在我当前路径的任何地方,或者在我的anaconda发行版中。有一个build/bdist.macosx-10.5-x86_64/目录,但没有egg。我的系统上有一些MachOGraph.py个文件,但它们都没有。此目录下的任何内容都不包含字符串loader.filename

发生了什么事?我怎样才能找到该文件?

为了完整性,这里是完整的追溯:

Traceback (most recent call last):
  File "/Users/mike/.continuum/anaconda/lib/python2.7/site-packages/ipdb/__main__.py", line 157, in main
    pdb._runscript(mainpyfile)
  File "/Users/mike/.continuum/anaconda/lib/python2.7/pdb.py", line 1233, in _runscript
    self.run(statement)
  File "/Users/mike/.continuum/anaconda/lib/python2.7/bdb.py", line 400, in run
    exec cmd in globals, locals
  File "<string>", line 1, in <module>
  File "setup.py", line 241, in <module>
    app = py2app_app
  File "/Users/mike/.continuum/anaconda/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/Users/mike/.continuum/anaconda/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/Users/mike/.continuum/anaconda/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/usr/local/src/Mnemosyne-2.3.1/py2app-0.8.1-py2.7.egg/py2app/build_app.py", line 654, in run
    self._run()
  File "/usr/local/src/Mnemosyne-2.3.1/py2app-0.8.1-py2.7.egg/py2app/build_app.py", line 860, in _run
    self.run_normal()
  File "/usr/local/src/Mnemosyne-2.3.1/py2app-0.8.1-py2.7.egg/py2app/build_app.py", line 950, in run_normal
    self.create_binaries(py_files, pkgdirs, extensions, loader_files)
  File "/usr/local/src/Mnemosyne-2.3.1/py2app-0.8.1-py2.7.egg/py2app/build_app.py", line 1110, in create_binaries
    platfiles = mm.run()
  File "build/bdist.macosx-10.5-x86_64/egg/macholib/MachOStandalone.py", line 105, in run
    mm.run_file(fn)
  File "build/bdist.macosx-10.5-x86_64/egg/macholib/MachOGraph.py", line 84, in run_file
    self.scan_node(m)
  File "build/bdist.macosx-10.5-x86_64/egg/macholib/MachOGraph.py", line 110, in scan_node
    m = self.load_file(filename, caller=node)
  File "build/bdist.macosx-10.5-x86_64/egg/macholib/MachOGraph.py", line 93, in load_file
    newname = self.locate(name, loader=caller)
  File "build/bdist.macosx-10.5-x86_64/egg/macholib/MachOStandalone.py", line 23, in locate
    newname = super(FilteredMachOGraph, self).locate(filename, loader)
  File "build/bdist.macosx-10.5-x86_64/egg/macholib/MachOGraph.py", line 49, in locate
    loader=loader.filename)
TypeError: dyld_find() got an unexpected keyword argument 'loader'

3 个答案:

答案 0 :(得分:2)

此问题是由 Pillow 引起的,您可以使用pip uninstall Pillow将其卸载,然后此问题就会消失。

答案 1 :(得分:0)

Python在打印回溯时采用字节码中报告的文件名。在这种情况下,字节码包含生成的Python egg文件名,这种格式至少包含字节码文件。这些路径反映了构建目录时相对于包的构建目录。

在这种情况下,py2app installer包含macholib作为安装要求; setuptools下载source code for that library并按需生成一个鸡蛋,与py2app鸡蛋位于同一位置。我在/usr/local/src/Mnemosyne-2.3.1/py2app-0.8.1-py2.7.egg查看macholib-1.6-py2.7.egg目录。

答案 2 :(得分:0)

使用 macholib1.7,来自** / MachOGraph.py的第46行......:

            try:
                fn = dyld_find(filename, env=self.env,
                    executable_path=self.executable_path,
                    loader=loader.filename)
                self.trans_table[(loader.filename, filename)] = fn
            except ValueError:
                return None

将第49行更改为:

                    loader_path=loader.filename)