py2app TypeError: dyld_find() got an unexpected keyword argument 'loader'

荒凉一梦 提交于 2019-11-29 07:06:30

This is a temporary solution, and it may break other things. I would recommend doing this is a virtual environment so you don't mess up your regular packages. This worked for me (virtenv is the name of my virtual environment)

Open the file /virtenv/lib/python3.4/site-packages/macholib/dyld.py and replace each instance of loader_path with loader. Now save and try again.

You can monkey-patch macholib rather than modifying it in site-packages. Place the following file to the directory containing setup_py2app.py and add import macholib_patch to the top.

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!