Python traceback points to non-existent file - python

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'

This issue is caused by Pillow, you can use pip uninstall Pillow to uninstall it, then this question will disappear.

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)

Related

Python pytest hangs. For instance, "pytest --version" simply hangs

The following hangs:
PS C:\Users\Fowler> pytest --version
Notes:
I am in Windows 10.
By hang, I mean at least 5 minutes of waiting for the pytest --version to return...
While waiting for pytest, python.exe is using 100% of a logical processor on my computer.
I uninstalled all python installations with windows installer and I reinistalled python 3.8.0 in an attempt to fix.
pytest only fails when I am not using a venv. So, pytest does work using a venv.
However, I can't use a venv with vscode, because debugging with venv gives a strange "Session-1 timed out waiting for debuggee to spawn" <-- you would think the word debuggee would be a nice clue, but not much found with that word on google. I am guessing this is a different problem, but maybe related?
In summary, I can't debug python with a venv, and I can't run pytest unit tests without a venv. Probably, these items are unrelated... But, because of this catch-22, I will be sooo grateful for any hints to fix either problem.
When I hit <ctrl-c> to break out of the pytest "hang", the following is displayed (but changes a little bit at the end each time?:
Traceback (most recent call last):
File "c:\program files\python38\lib\runpy.py", line 192, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\program files\python38\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\Scripts\pytest.exe\__main__.py", line 7, in <module>
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\_pytest\config\__init__.py", line 72, in main
config = _prepareconfig(args, plugins)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\_pytest\config\__init__.py", line 222, in _prepareconfig
return pluginmanager.hook.pytest_cmdline_parse(
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\pluggy\hooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\pluggy\manager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\pluggy\manager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\pluggy\callers.py", line 203, in _multicall
gen.send(outcome)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\_pytest\helpconfig.py", line 89, in pytest_cmdline_parse
config = outcome.get_result()
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\pluggy\callers.py", line 80, in get_result
raise ex[1].with_traceback(ex[2])
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\pluggy\callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\_pytest\config\__init__.py", line 742, in pytest_cmdline_parse
self.parse(args)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\_pytest\config\__init__.py", line 948, in parse
self._preparse(args, addopts=addopts)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\_pytest\config\__init__.py", line 896, in _preparse
self.pluginmanager.load_setuptools_entrypoints("pytest11")
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\pluggy\manager.py", line 299, in load_setuptools_entrypoints
plugin = ep.load()
File "c:\program files\python38\lib\importlib\metadata.py", line 75, in load
module = import_module(match.group('module'))
File "c:\program files\python38\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\_pytest\assertion\rewrite.py", line 138, in exec_module
_write_pyc(state, co, source_stat, pyc)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\_pytest\assertion\rewrite.py", line 274, in _write_pyc
with atomic_write(fspath(pyc), mode="wb", overwrite=True) as fp:
File "c:\program files\python38\lib\contextlib.py", line 113, in __enter__
return next(self.gen)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\atomicwrites\__init__.py", line 156, in _open
with get_fileobject(**self._open_kwargs) as f:
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\atomicwrites\__init__.py", line 173, in get_fileobject
descriptor, name = tempfile.mkstemp(suffix=suffix, prefix=prefix,
File "c:\program files\python38\lib\tempfile.py", line 332, in mkstemp
return _mkstemp_inner(dir, prefix, suffix, flags, output_type)
File "c:\program files\python38\lib\tempfile.py", line 247, in _mkstemp_inner
file = _os.path.join(dir, pre + name + suf)
KeyboardInterrupt
The next time try to run pytest --version and I hit <ctrl-c> it ends with:
Traceback (most recent call last):
File "c:\program files\python38\lib\runpy.py", line 192, in _run_module_as_main
return _run_code(code, main_globals, None,
...
...
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\atomicwrites\__init__.py", line 173, in get_fileobject
descriptor, name = tempfile.mkstemp(suffix=suffix, prefix=prefix,
File "c:\program files\python38\lib\tempfile.py", line 332, in mkstemp
return _mkstemp_inner(dir, prefix, suffix, flags, output_type)
File "c:\program files\python38\lib\tempfile.py", line 248, in _mkstemp_inner
_sys.audit("tempfile.mkstemp", file)
KeyboardInterrupt
The next time try to run pytest --version and I hit <ctrl-c> it ends with:
Traceback (most recent call last):
File "c:\program files\python38\lib\runpy.py", line 192, in _run_module_as_main
return _run_code(code, main_globals, None,
...
...
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\atomicwrites\__init__.py", line 173, in get_fileobject
descriptor, name = tempfile.mkstemp(suffix=suffix, prefix=prefix,
File "c:\program files\python38\lib\tempfile.py", line 332, in mkstemp
return _mkstemp_inner(dir, prefix, suffix, flags, output_type)
File "c:\program files\python38\lib\tempfile.py", line 256, in _mkstemp_inner
if (_os.name == 'nt' and _os.path.isdir(dir) and
File "c:\program files\python38\lib\genericpath.py", line 42, in isdir
st = os.stat(s)
KeyboardInterrupt
The next time try to run pytest --version and I hit <ctrl-c> it ends with:
Traceback (most recent call last):
File "c:\program files\python38\lib\runpy.py", line 192, in _run_module_as_main
return _run_code(code, main_globals, None,
...
...
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\atomicwrites\__init__.py", line 173, in get_fileobject
descriptor, name = tempfile.mkstemp(suffix=suffix, prefix=prefix,
File "c:\program files\python38\lib\tempfile.py", line 332, in mkstemp
return _mkstemp_inner(dir, prefix, suffix, flags, output_type)
File "c:\program files\python38\lib\tempfile.py", line 250, in _mkstemp_inner
fd = _os.open(file, flags, 0o600)
KeyboardInterrupt
I don't know if this output will help, but I thought it might be useful to see all the locations on my machine where python and/or pytest are installed:
PS C:\Users\Fowler> where.exe /r c:\ python
c:\Program Files\Amazon\AWSCLI\runtime\python.exe
c:\Program Files\Amazon\AWSSAMCLI\runtime\python.exe
c:\Program Files\MySQL\MySQL Workbench 8.0 CE\python.exe
c:\Program Files\Python38\python.exe
c:\Program Files\Python38\Lib\venv\scripts\nt\python.exe
c:\Users\Fowler\.vscode\extensions\lextudio.restructuredtext-116.0.0\out\python.js
c:\Users\Fowler\.vscode\extensions\teabyii.ayu-0.18.0\test\Python.py
c:\Users\Fowler\.vscode\extensions\yzane.markdown-pdf-1.4.1\node_modules\highlight.js\lib\languages\python.js
c:\Users\Fowler\AppData\Local\GitHubDesktop\app-2.2.2\resources\app\highlighter\mode\python.js
c:\Users\Fowler\AppData\Local\GitHubDesktop\app-2.2.3\resources\app\highlighter\mode\python.js
c:\Users\Fowler\AppData\Local\Google\Chrome\User Data\Default\Extensions\ngkhgikojglcgnckopipfdajaifmmnnc\4.1.34_0\python.js
c:\Users\Fowler\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\etc\apparmor.d\abstractions\python
c:\Users\Fowler\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\usr\share\bash-completion\completions\python
c:\Users\Fowler\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\usr\share\bash-completion\helpers\python
c:\Users\Fowler\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\usr\share\sosreport\sos\plugins\python.py
c:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\aniso8601\builders\python.py
c:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\_pytest\python.py
c:\Users\Fowler\Documents\vscodeProjects\playarea\.venv\Scripts\python.exe
c:\Windows\Installer\$PatchCache$\Managed\8B9C64EBE8DD53846B6846E46A14F5EE\3.7.2150\python.exe
c:\Windows\Installer\$PatchCache$\Managed\9CB0624238F6F8F469EAD6566412DD7F\3.7.2150\python.exe
PS C:\Users\Fowler> where.exe /r c:\ pytest
c:\Users\Fowler\AppData\Roaming\Python\Python38\Scripts\pytest.exe
c:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\pytest.py
And finally! Whew, in case this sheds any light, here is a picture showing the python process having fun eating up my CPU during pytest.py...
I would be oh, so grateful for any assistance or thoughts!
Fixed.
The answer appears to be
Uninstall python via the windows apps and features
Remove the c:\program files\python38 directory
Remove the ..\AppData\Roaming\Python directory
Reinstall
Not sure what the "root" problem was, but a total wipe of python fixed it. Note that the python windows installer does not remove enough python stuff.
Thank you #nneonneo for getting me thinking in the right direction.
You can just run pytest from priviledged (admin) cmd for the first time. For me the issue was fixed and pytest runs from ordinary cmd now without hanging.
I have the similar problem
after i install pytest-cov or allure-pytest, pytest will hang
if i uninstall them , everything is back to normal
I have tried to install different pytest version, It didn't help
but, I tried the method you provide(uninstall python, remove the diretories), it works~, great!
but, when I install allure-pytest again, it fails again.
finally, I found that, I can't install package in privilege cmd window
If I install them in privilege cmd windows, it will make pytest hang!
so, if anyone encounter the problem I have, you can try my way.
In my case, the package anyio, a dependency of JupyterLab, was causing this problem. It was installed at the administrator level. I uninstalled it and reinstalled at the user level and pytest started working again.
Using Ubuntu 18.04/20.04 + Python 3.8.2
My tests were hanging in a similar matter after showing results.
Removing pytest-cov didn't help.
What helped was moving from Python 3.8.2 to a newer version (like 3.8.12)
I ran into the same issue. In my case my IDE didn't load the correct conda environment. So make sure you're in the right environment for your application and use conda activate myEnv to change it if necessary.

Buiding with distutils gives TypeError: expected str, bytes or os.PathLike object, not list

I am trying to build the sklearn.tree subpackage, which includes some Cython code. I use Python 3.6.1 on Windows with Numpy 1.12.1.
The file setup.py (can be downloaded here) contains distutils configuration with code such as
config.add_extension("_tree", sources=["_tree.pyx"],...)
So I expect that sources (this variable flops through a long stack of functions listed below) is a list of strings.
However, when trying to build the package, I recieve the output listed below. It implies that the source in functions in the build_src.py, an element of sources, is not a string but a list.
So the questions are:
Did the string indeed turn into a list; if so, where?
Is this error caused by the way I build the module; if so, how to build it correctly?
Is this error caused by the way setup.py is written? If so, how to change it? And how did developers of sklearn use it?
Is this error caused by my environment? If so, what should I change?
C:\Users\ddale\Downloads\scikit-learn-master\sklearn\tree>python setup.py build_ext
Appending tree.tests configuration to tree
Ignoring attempt to set 'name' (from 'tree' to 'tree.tests')
running build_ext
running build_src
build_src
building extension "tree._tree" sources
Warning: Assuming default configuration (tests/{setup_tests,setup}.py was not found)Traceback (most recent call last):
File "setup.py", line 39, in <module>
setup(**configuration_old().todict())
File "C:\Users\ddale\AppData\Local\Continuum\Anaconda3\lib\site-packages\numpy\distutils\core.py", line 166, in setup
return old_setup(**new_attr)
File "C:\Users\ddale\AppData\Local\Continuum\Anaconda3\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Users\ddale\AppData\Local\Continuum\Anaconda3\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "C:\Users\ddale\AppData\Local\Continuum\Anaconda3\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\ddale\AppData\Local\Continuum\Anaconda3\lib\site-packages\numpy\distutils\command\build_ext.py", line 82, in run
self.run_command('build_src')
File "C:\Users\ddale\AppData\Local\Continuum\Anaconda3\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Users\ddale\AppData\Local\Continuum\Anaconda3\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\ddale\AppData\Local\Continuum\Anaconda3\lib\site-packages\numpy\distutils\command\build_src.py", line 148, in run
self.build_sources()
File "C:\Users\ddale\AppData\Local\Continuum\Anaconda3\lib\site-packages\numpy\distutils\command\build_src.py", line 165, in build_sources
self.build_extension_sources(ext)
File "C:\Users\ddale\AppData\Local\Continuum\Anaconda3\lib\site-packages\numpy\distutils\command\build_src.py", line 330, in build_extension_sources
sources, py_files = self.filter_py_files(sources)
File "C:\Users\ddale\AppData\Local\Continuum\Anaconda3\lib\site-packages\numpy\distutils\command\build_src.py", line 390, in filter_py_files
return self.filter_files(sources, ['.py'])
File "C:\Users\ddale\AppData\Local\Continuum\Anaconda3\lib\site-packages\numpy\distutils\command\build_src.py", line 399, in filter_files
(base, ext) = os.path.splitext(source)
File "C:\Users\ddale\AppData\Local\Continuum\Anaconda3\lib\ntpath.py", line 223, in splitext
p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not list

NameError py2app in modulegraph

I'm trying to use py2app to create a standalone application of mac. When I`m using the alias mode everything work fine, but when I try to
python setup.py py2app
I receive this error:
Traceback (most recent call last):
File "setup.py", line 21, in <module>
setup_requires=['py2app'],
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/Users/robert/Envs/py36/lib/python3.6/site-packages/py2app/build_app.py", line 659, in run
self._run()
File "/Users/robert/Envs/py36/lib/python3.6/site-packages/py2app/build_app.py", line 865, in _run
self.run_normal()
File "/Users/robert/Envs/py36/lib/python3.6/site-packages/py2app/build_app.py", line 943, in run_normal
self.process_recipes(mf, filters, flatpackages, loader_files)
File "/Users/robert/Envs/py36/lib/python3.6/site-packages/py2app/build_app.py", line 824, in process_recipes
rval = check(self, mf)
File "/Users/robert/Envs/py36/lib/python3.6/site-packages/py2app/recipes/virtualenv.py", line 86, in check
mf._scan_code(co, m)
File "/Users/robert/Envs/py36/lib/python3.6/site-packages/modulegraph/modulegraph.py", line 1543, in _scan_code
self._scan_bytecode(co, m)
File "/Users/robert/Envs/py36/lib/python3.6/site-packages/modulegraph/modulegraph.py", line 1570, in _scan_bytecode
n = len(code)
NameError: name 'code' is not defined
My version of Python 3.5, py2app 0.10, module graph 0.13. Has anyone encountered a similar one, and how I can solve it?
P.S. Sorry for my bad English.
I had the same issue.
This issue will be fixed in moudulegraph 0.14
If you can't wait you can pull from the repo any point after this commit:
https://bitbucket.org/ronaldoussoren/modulegraph/commits/32c6c60f9dcdb106219a1476218e0d364cb11255

compiling python script to exe with py2exe, getting error

So I have a script called papercutter.py and a setup.py that is set up as follows according to the py2exe tutorial:
from distutils.core import setup
import py2exe
setup(console=['papercutter.py'])
So following the tutorial, i run python setup.py py2exe and it looks successful:
c:\Codes>python setup.py install
running install
running build
running install_egg_info
Removing C:\Python\Lib\site-packages\UNKNOWN-0.0.0-py3.6.egg-info
Writing C:\Python\Lib\site-packages\UNKNOWN-0.0.0-py3.6.egg-info
but when I run the next step, python setup.py py2exe, I get error:
c:\Codes>python setup.py py2exe
running py2exe
Traceback (most recent call last):
File "setup.py", line 4, in <module>
setup(console=['papercutter.py'])
File "C:\Python\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Python\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "C:\Python\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Python\lib\site-packages\py2exe\distutils_buildexe.py", line 188, in run
self._run()
File "C:\Python\lib\site-packages\py2exe\distutils_buildexe.py", line 267, in _run
builder.analyze()
File "C:\Python\lib\site-packages\py2exe\runtime.py", line 157, in analyze
self.mf.import_package(modname[:-2])
File "C:\Python\lib\site-packages\py2exe\mf3.py", line 91, in import_package
self.import_hook(name)
File "C:\Python\lib\site-packages\py2exe\mf3.py", line 117, in import_hook
module = self._gcd_import(name)
File "C:\Python\lib\site-packages\py2exe\mf3.py", line 267, in _gcd_import
return self._find_and_load(name)
File "C:\Python\lib\site-packages\py2exe\mf3.py", line 320, in _ find_and_load
self._scan_code(module.__code__, module)
File "C:\Python\lib\site-packages\py2exe\mf3.py", line 352, in _scan_code
for what, args in self._scan_opcodes(code):
File "C:\Python\lib\site-packages\py2exe\mf3.py", line 381, in _scan_opcodes
yield "store", (names[oparg],)
IndexError: tuple index out of range
What am I doing wrong here?
Note: this is the tutorial I am following: http://www.py2exe.org/index.cgi/Tutorial
Also note: I am using py2exe 0.9.2.0 and python 3.6.0. I think these should be fine together.
The answer is at the bottom of the Traceback. Seems like you have an indexing problem with a tuple. Indexes are 0 based in Python.
Currently py2exe supports Python up to 3.4

Py2App: Alias mode works, but deployment doesn't

I'm trying to deploy my python application using py2app.
I created the setup file using : py2applet --make-setup MyApplication.py
Then I did this to test it : python setup.py py2app -A
That worked as well. My GUI program runs.
When I try the last step: python setup.py py2app
I get this fat error.
Traceback (most recent call last):
File "setup.py", line 18, in <module>
setup_requires=['py2app'],
File "/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/local/lib/python2.7/site-packages/py2app/build_app.py", line 659, in run
self._run()
File "/usr/local/lib/python2.7/site-packages/py2app/build_app.py", line 865, in _run
self.run_normal()
File "/usr/local/lib/python2.7/site-packages/py2app/build_app.py", line 959, in run_normal
self.create_binaries(py_files, pkgdirs, extensions, loader_files)
File "/usr/local/lib/python2.7/site-packages/py2app/build_app.py", line 1214, in create_binaries
platfiles = mm.run()
File "/usr/local/lib/python2.7/site-packages/macholib/MachOStandalone.py", line 105, in run
mm.run_file(fn)
File "/usr/local/lib/python2.7/site-packages/macholib/MachOGraph.py", line 84, in run_file
self.scan_node(m)
File "/usr/local/lib/python2.7/site-packages/macholib/MachOGraph.py", line 110, in scan_node
m = self.load_file(filename, caller=node)
File "/usr/local/lib/python2.7/site-packages/macholib/MachOGraph.py", line 93, in load_file
newname = self.locate(name, loader=caller)
File "/usr/local/lib/python2.7/site-packages/macholib/MachOStandalone.py", line 23, in locate
newname = super(FilteredMachOGraph, self).locate(filename, loader)
File "/usr/local/lib/python2.7/site-packages/macholib/MachOGraph.py", line 49, in locate
loader=loader.filename)
TypeError: dyld_find() got an unexpected keyword argument 'loader'
Why is this happening? I've spend the last few hours trying to deploy. No luck with py2app, cx_freeze, etc.
Here is a workaround: edit the file MachOGraph.py which in your case is located there:
/usr/local/lib/python2.7/site-packages/macholib/MachOGraph.py
Search for the term loader=loader.filename) and replace it with loader_path=loader.filename)
Credits goes to David Goldenberg for its post on bitbucket.org. https://bitbucket.org/ronaldoussoren/py2app/issues/137/py2app-problems-using-enthought-python
Pillow was the problem. Py2Applet doesn't play nice with it. Got rid of Pillow, and all is well.

Categories