简体   繁体   中英

Python traceback points to non-existent file

I'm trying to run a setup.py script (for mnemosyne ). The script fails, and I'm pretty sure I know how to fix the problem, if I could only find the file to edit. The problem is that the traceback points to a non-existent file:

  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'

I believe that should be loader_path . The problem is that MachOGraph.py file doesn't exist -- not anywhere in my current path, or in my anaconda distribution. There is a build/bdist.macosx-10.5-x86_64/ directory, but no egg . There are a few MachOGraph.py files on my system, but none of them have that line. Nothing under this directory contains the string loader.filename .

What's going on? How can I find that file?

For completeness, here is the complete traceback:

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'

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

Python takes the filename as reported in the bytecode when printing a traceback. In this case, the bytecode contains filenames that are generated to produce a Python egg , a format that contains at least the bytecode files. These paths reflect the build directory relative to the package as it was built.

In this case, it is the py2app installer that includes macholib as a installation requirement; setuptools downloads the source code for that library and produces an egg on demand, in the same location as the py2app egg. I'd look in /usr/local/src/Mnemosyne-2.3.1/py2app-0.8.1-py2.7.egg for a macholib-1.6-py2.7.egg directory.

With macholib1.7, from line 46 of **/MachOGraph.py...:

            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

Change line 49 to:

                    loader_path=loader.filename)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM