使用py2app进行编译时尝试包含pip模块时出现以下错误:
running py2app
creating /Users/gryphon/Desktop/py2app test/build
creating /Users/gryphon/Desktop/py2app test/build/bdist.macosx-10.6-intel
creating /Users/gryphon/Desktop/py2app test/build/bdist.macosx-10.6-intel/python3.6-standalone
creating /Users/gryphon/Desktop/py2app test/build/bdist.macosx-10.6-intel/python3.6-standalone/app
creating /Users/gryphon/Desktop/py2app test/build/bdist.macosx-10.6-intel/python3.6-standalone/app/collect
creating /Users/gryphon/Desktop/py2app test/build/bdist.macosx-10.6-intel/python3.6-standalone/app/temp
creating /Users/gryphon/Desktop/py2app test/dist
creating build/bdist.macosx-10.6-intel/python3.6-standalone/app/lib-dynload
creating build/bdist.macosx-10.6-intel/python3.6-standalone/app/Frameworks
Traceback (most recent call last):
File "setup.py", line 9, in <module>
setup_requires=['py2app'],
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/setuptools/__init__.py", line 129, in setup
return distutils.core.setup(**attrs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/Users/gryphon/Desktop/py2app test/.eggs/py2app-0.17-py3.6.egg/py2app/build_app.py", line 838, in run
self._run()
File "/Users/gryphon/Desktop/py2app test/.eggs/py2app-0.17-py3.6.egg/py2app/build_app.py", line 1053, in _run
self.run_normal()
File "/Users/gryphon/Desktop/py2app test/.eggs/py2app-0.17-py3.6.egg/py2app/build_app.py", line 1146, in run_normal
mf = self.get_modulefinder()
File "/Users/gryphon/Desktop/py2app test/.eggs/py2app-0.17-py3.6.egg/py2app/build_app.py", line 997, in get_modulefinder
debug=debug,
File "/Users/gryphon/Desktop/py2app test/.eggs/modulegraph-0.17-py3.6.egg/modulegraph/find_modules.py", line 338, in find_modules
find_needed_modules(mf, scripts, includes, packages)
File "/Users/gryphon/Desktop/py2app test/.eggs/modulegraph-0.17-py3.6.egg/modulegraph/find_modules.py", line 256, in find_needed_modules
path = m.packagepath[0]
TypeError: 'NoneType' object is not subscriptable
Ethans-MacBook-Pro:py2app test gryphon$ clear
Ethans-MacBook-Pro:py2app test gryphon$ sudo python3 setup.py py2app
Password:
running py2app
creating /Users/gryphon/Desktop/py2app test/build
creating /Users/gryphon/Desktop/py2app test/build/bdist.macosx-10.6-intel
creating /Users/gryphon/Desktop/py2app test/build/bdist.macosx-10.6-intel/python3.6-standalone
creating /Users/gryphon/Desktop/py2app test/build/bdist.macosx-10.6-intel/python3.6-standalone/app
creating /Users/gryphon/Desktop/py2app test/build/bdist.macosx-10.6-intel/python3.6-standalone/app/collect
creating /Users/gryphon/Desktop/py2app test/build/bdist.macosx-10.6-intel/python3.6-standalone/app/temp
creating /Users/gryphon/Desktop/py2app test/dist
creating build/bdist.macosx-10.6-intel/python3.6-standalone/app/lib-dynload
creating build/bdist.macosx-10.6-intel/python3.6-standalone/app/Frameworks
Traceback (most recent call last):
File "setup.py", line 9, in <module>
setup_requires=['py2app'],
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/setuptools/__init__.py", line 129, in setup
return distutils.core.setup(**attrs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/Users/gryphon/Desktop/py2app test/.eggs/py2app-0.17-py3.6.egg/py2app/build_app.py", line 838, in run
self._run()
File "/Users/gryphon/Desktop/py2app test/.eggs/py2app-0.17-py3.6.egg/py2app/build_app.py", line 1053, in _run
self.run_normal()
File "/Users/gryphon/Desktop/py2app test/.eggs/py2app-0.17-py3.6.egg/py2app/build_app.py", line 1146, in run_normal
mf = self.get_modulefinder()
File "/Users/gryphon/Desktop/py2app test/.eggs/py2app-0.17-py3.6.egg/py2app/build_app.py", line 997, in get_modulefinder
debug=debug,
File "/Users/gryphon/Desktop/py2app test/.eggs/modulegraph-0.17-py3.6.egg/modulegraph/find_modules.py", line 338, in find_modules
find_needed_modules(mf, scripts, includes, packages)
File "/Users/gryphon/Desktop/py2app test/.eggs/modulegraph-0.17-py3.6.egg/modulegraph/find_modules.py", line 256, in find_needed_modules
path = m.packagepath[0]
TypeError: 'NoneType' object is not subscriptable
Ethans-MacBook-Pro:py2app test gryphon$ cls
-bash: cls: command not found
Ethans-MacBook-Pro:py2app test gryphon$ clear
Ethans-MacBook-Pro:py2app test gryphon$ sudo python3 setup.py py2app
Password:
running py2app
creating /Users/gryphon/Desktop/py2app test/build/bdist.macosx-10.6-intel/python3.6-standalone/app
creating /Users/gryphon/Desktop/py2app test/build/bdist.macosx-10.6-intel/python3.6-standalone/app/collect
creating /Users/gryphon/Desktop/py2app test/build/bdist.macosx-10.6-intel/python3.6-standalone/app/temp
creating build/bdist.macosx-10.6-intel/python3.6-standalone/app/lib-dynload
creating build/bdist.macosx-10.6-intel/python3.6-standalone/app/Frameworks
Traceback (most recent call last):
File "setup.py", line 9, in <module>
setup_requires=['py2app'],
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/setuptools/__init__.py", line 129, in setup
return distutils.core.setup(**attrs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/Users/gryphon/Desktop/py2app test/.eggs/py2app-0.17-py3.6.egg/py2app/build_app.py", line 838, in run
self._run()
File "/Users/gryphon/Desktop/py2app test/.eggs/py2app-0.17-py3.6.egg/py2app/build_app.py", line 1053, in _run
self.run_normal()
File "/Users/gryphon/Desktop/py2app test/.eggs/py2app-0.17-py3.6.egg/py2app/build_app.py", line 1146, in run_normal
mf = self.get_modulefinder()
File "/Users/gryphon/Desktop/py2app test/.eggs/py2app-0.17-py3.6.egg/py2app/build_app.py", line 997, in get_modulefinder
debug=debug,
File "/Users/gryphon/Desktop/py2app test/.eggs/modulegraph-0.17-py3.6.egg/modulegraph/find_modules.py", line 338, in find_modules
find_needed_modules(mf, scripts, includes, packages)
File "/Users/gryphon/Desktop/py2app test/.eggs/modulegraph-0.17-py3.6.egg/modulegraph/find_modules.py", line 256, in find_needed_modules
path = m.packagepath[0]
TypeError: 'NoneType' object is not subscriptable
我的setup.py:
from setuptools import setup
APP = ['test.py']
OPTIONS = {'argv_emulation': True, "packages": ["requests"]}
setup(
app=APP,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
Test.py:
import requests
requests.get("https://www.youtube.com")
print("Hello")
仅使用输入(删除请求)时,一切正常,但是,每当尝试包含pip模块时,我都会报错。如果我未在setup.py中包含pip模块,则会收到一条错误消息,提示找不到它们。我尝试在py2app之后添加--packages = requests标志,但遇到相同的错误。