py2app TypeError: dyld_find() got an unexpected keyword argument 'loader'
py2app TypeError: dyld_find() got an unexpected keyword argument 'loader'
我在使用 py2app 构建我的应用程序时遇到了困难。我可以使用此命令以别名模式毫无问题地构建它:
python3.4 setup.py py2app -A
然而,当我尝试使用以下方法构建它时:
python3.4 setup.py py2app
我收到与此 post 标题相同的错误消息。根据我所做的研究,我认为这是 Pillow 的问题;但是我需要这个应用程序的枕头。 (除非我可以使用另一个模块来导入图像??)。我也试过 cx_freeze 但没有成功。
非常感谢任何帮助或指导。
完整回溯如下:
Traceback (most recent call last):
File "setup.py", line 19, in <module>
setup_requires=['py2app'],
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
distutils/core.py", line 148, in setup dist.run_commands()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
distutils/dist.py", line 955, in run_commands self.run_command(cmd)
File"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
distutils/dist.py", line 974, in run_command cmd_obj.run()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site- packages/py2app/build_app.py", line 659, in run self._run()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site- packages/py2app/build_app.py", line 865, in _run self.run_normal()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site- packages/py2app/build_app.py", line 959, in
run_normal self.create_binaries(py_files, pkgdirs, extensions,loader_files)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site- packages/py2app/build_app.py", line 1214, in create_binaries
platfiles = mm.run()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site-packages/macholib/MachOStandalone.py", line 105, in run
mm.run_file(fn)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site-packages/macholib/MachOGraph.py", line 84, in run_file
self.scan_node(m)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site-packages/macholib/MachOGraph.py", line 110, in scan_node
m = self.load_file(filename, caller=node)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site-packages/macholib/MachOGraph.py", line 93, in load_file
newname = self.locate(name, loader=caller)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site-packages/macholib/MachOStandalone.py", line 23, in locate
newname = super(FilteredMachOGraph, self).locate(filename, loader)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site-packages/macholib/MachOGraph.py", line 49, in locate
loader=loader.filename)
TypeError: dyld_find() got an unexpected keyword argument 'loader'
这是一个临时解决方案,它可能会破坏其他东西。我建议这样做是一个虚拟环境,这样你就不会弄乱你的常规包裹。这对我有用(virtenv 是我的虚拟环境的名称)
打开文件 /virtenv/lib/python3.4/site-packages/macholib/dyld.py
并将 loader_path
的每个实例替换为 loader
。现在保存并重试。
您可以猴子修补 macholib 而不是在站点包中修改它。将以下文件放入包含 setup_py2app.py 的目录,并在顶部添加 import macholib_patch
。
macholib_patch.py:
"""
Monkey-patch macholib to fix "dyld_find() got an unexpected keyword argument 'loader'".
Add 'import macholib_patch' to the top of set_py2app.py
"""
import macholib
#print("~"*60 + "macholib verion: "+macholib.__version__)
if macholib.__version__ <= "1.7":
print("Applying macholib patch...")
import macholib.dyld
import macholib.MachOGraph
dyld_find_1_7 = macholib.dyld.dyld_find
def dyld_find(name, loader=None, **kwargs):
#print("~"*60 + "calling alternate dyld_find")
if loader is not None:
kwargs['loader_path'] = loader
return dyld_find_1_7(name, **kwargs)
macholib.MachOGraph.dyld_find = dyld_find
我在使用 py2app 构建我的应用程序时遇到了困难。我可以使用此命令以别名模式毫无问题地构建它:
python3.4 setup.py py2app -A
然而,当我尝试使用以下方法构建它时:
python3.4 setup.py py2app
我收到与此 post 标题相同的错误消息。根据我所做的研究,我认为这是 Pillow 的问题;但是我需要这个应用程序的枕头。 (除非我可以使用另一个模块来导入图像??)。我也试过 cx_freeze 但没有成功。
非常感谢任何帮助或指导。
完整回溯如下:
Traceback (most recent call last):
File "setup.py", line 19, in <module>
setup_requires=['py2app'],
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
distutils/core.py", line 148, in setup dist.run_commands()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
distutils/dist.py", line 955, in run_commands self.run_command(cmd)
File"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
distutils/dist.py", line 974, in run_command cmd_obj.run()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site- packages/py2app/build_app.py", line 659, in run self._run()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site- packages/py2app/build_app.py", line 865, in _run self.run_normal()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site- packages/py2app/build_app.py", line 959, in
run_normal self.create_binaries(py_files, pkgdirs, extensions,loader_files)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site- packages/py2app/build_app.py", line 1214, in create_binaries
platfiles = mm.run()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site-packages/macholib/MachOStandalone.py", line 105, in run
mm.run_file(fn)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site-packages/macholib/MachOGraph.py", line 84, in run_file
self.scan_node(m)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site-packages/macholib/MachOGraph.py", line 110, in scan_node
m = self.load_file(filename, caller=node)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site-packages/macholib/MachOGraph.py", line 93, in load_file
newname = self.locate(name, loader=caller)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site-packages/macholib/MachOStandalone.py", line 23, in locate
newname = super(FilteredMachOGraph, self).locate(filename, loader)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site-packages/macholib/MachOGraph.py", line 49, in locate
loader=loader.filename)
TypeError: dyld_find() got an unexpected keyword argument 'loader'
这是一个临时解决方案,它可能会破坏其他东西。我建议这样做是一个虚拟环境,这样你就不会弄乱你的常规包裹。这对我有用(virtenv 是我的虚拟环境的名称)
打开文件 /virtenv/lib/python3.4/site-packages/macholib/dyld.py
并将 loader_path
的每个实例替换为 loader
。现在保存并重试。
您可以猴子修补 macholib 而不是在站点包中修改它。将以下文件放入包含 setup_py2app.py 的目录,并在顶部添加 import macholib_patch
。
macholib_patch.py:
"""
Monkey-patch macholib to fix "dyld_find() got an unexpected keyword argument 'loader'".
Add 'import macholib_patch' to the top of set_py2app.py
"""
import macholib
#print("~"*60 + "macholib verion: "+macholib.__version__)
if macholib.__version__ <= "1.7":
print("Applying macholib patch...")
import macholib.dyld
import macholib.MachOGraph
dyld_find_1_7 = macholib.dyld.dyld_find
def dyld_find(name, loader=None, **kwargs):
#print("~"*60 + "calling alternate dyld_find")
if loader is not None:
kwargs['loader_path'] = loader
return dyld_find_1_7(name, **kwargs)
macholib.MachOGraph.dyld_find = dyld_find