[英]py2app can't find installed and included package
I'm trying to build a .app with py2app that launches a Flask app, locally (at the moment neither hosting the app, nor using pyinstaller, are options). 我正在尝试使用py2app构建一个.app,在本地启动Flask应用程序(目前既不托管应用程序,也不使用pyinstaller,是选项)。
I'm building my setup.py with: 我正在构建我的setup.py:
python setup.py py2app --packages=jinja2,flask,message
And my setup.py looks like: 我的setup.py看起来像:
from setuptools import setup
APP = ['Glutton.py']
DATA_FILES = []
PKGS = ['jinja2', 'flask', 'message']
OPTIONS = {'argv_emulation': True,
'iconfile': '/blahblahblah/glutton.icns',
'packages': PKGS
}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app', 'flask', 'jinja2', 'message'],
)
However, in the console, I'm getting ImportError: No module named message
despite message being installed, and loading fine from a python REPL, and being explicitly included both in setup.py
, and the py2app command line call. 但是,在控制台中,我得到
ImportError: No module named message
尽管安装了消息,并且从python REPL加载正常,并且明确包含在setup.py
和py2app命令行调用中。
Here's the full traceback: 这是完整的追溯:
10/27/15 3:34:45.195 PM Glutton[51755]: Traceback (most recent call last):
10/27/15 3:34:45.195 PM Glutton[51755]: File "/Users/alexloewi/Documents/Sites/glutton/dist/Glutton.app/Contents/Resources/Glutton.py", line 182, in <module>
10/27/15 3:34:45.195 PM Glutton[51755]: app.run(debug=True) # Can cause the tabe to open multiple times --
10/27/15 3:34:45.195 PM Glutton[51755]: File "/Users/alexloewi/Documents/Sites/glutton/dist/Glutton.app/Contents/Resources/lib/python2.7/flask/app.py", line 772, in run
10/27/15 3:34:45.451 PM Glutton[51755]: run_simple(host, port, self, **options)
10/27/15 3:34:45.451 PM Glutton[51755]: File "/Users/alexloewi/Documents/Sites/glutton/dist/Glutton.app/Contents/Resources/lib/python2.7/werkzeug/serving.py", line 708, in run_simple
10/27/15 3:34:45.640 PM Glutton[51755]: run_with_reloader(inner, extra_files, reloader_interval)
10/27/15 3:34:45.640 PM Glutton[51755]: File "/Users/alexloewi/Documents/Sites/glutton/dist/Glutton.app/Contents/Resources/lib/python2.7/werkzeug/serving.py", line 613, in run_with_reloader
10/27/15 3:34:45.640 PM Glutton[51755]: reloader_loop(extra_files, interval)
10/27/15 3:34:45.640 PM Glutton[51755]: File "/Users/alexloewi/Documents/Sites/glutton/dist/Glutton.app/Contents/Resources/lib/python2.7/werkzeug/serving.py", line 519, in _reloader_stat_loop
10/27/15 3:34:45.641 PM Glutton[51755]: for filename in chain(_iter_module_files(), extra_files or ()):
10/27/15 3:34:45.641 PM Glutton[51755]: File "/Users/alexloewi/Documents/Sites/glutton/dist/Glutton.app/Contents/Resources/lib/python2.7/werkzeug/serving.py", line 493, in _iter_module_files
10/27/15 3:34:45.641 PM Glutton[51755]: filename = getattr(module, '__file__', None)
10/27/15 3:34:45.641 PM Glutton[51755]: File "email/__init__.pyc", line 79, in __getattr__
10/27/15 3:34:45.741 PM Glutton[51755]: ImportError
10/27/15 3:34:45.741 PM Glutton[51755]: ImportError: No module named message
Thing is, I'm only including 'message' in the FIRST place because when I try to RUN my app (built WITHOUT mention of 'message'), the py2app console tells me there's no such module. 事实是,我只在第一个地方包含'消息',因为当我尝试运行我的应用程序(没有提到'消息')时,py2app控制台告诉我没有这样的模块。 I'm not even sure what's asking for it -- I certainly don't, and it all runs fine when launched manually.
我甚至不确定是什么要求它 - 我当然不会,并且在手动启动时一切正常。 Again looking at the console it appears to be werkzeug, but when I try to include it explicitly as well (I thought flask does that automatically), message still can't be found.
再次看控制台它似乎是werkzeug,但当我尝试明确地包括它(我认为烧瓶自动执行),仍然无法找到消息。
My best guess is that is a multiple pythons/virtual environment thing, but I don't know much/anything about that, and it seems like a dark and foreboding rabbit hole without a much deeper understanding of py2app. 我最好的猜测是,这是一个多蟒蛇/虚拟环境的事情,但我不知道太多/任何关于这一点,它似乎是一个黑暗和不祥的兔子洞,没有更深入理解py2app。
Many thanks, 非常感谢,
Are the modules 'flask', 'jinja2', 'message' just .py files or are they full packages with itit .py files in them? 模块'flask','jinja2','message'只是.py文件还是包含itit .py文件的完整包?
try: 尝试:
setup(py_modules=['flask', 'jinja2', 'message']
if they are .py modules that you created and call from 'Glutton.py' 如果它们是您创建的.py模块并从'Glutton.py'调用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.