py2app找不到已安装和包含的包

时间:2015-10-27 19:25:06

标签: python flask importerror py2app

我正在尝试使用py2app构建一个.app,在本地启动Flask应用程序(目前既不托管应用程序,也不使用pyinstaller,是选项)。

我正在构建我的setup.py:

python setup.py py2app --packages=jinja2,flask,message

我的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'],
)

然而,在控制台中,我得到ImportError: No module named message 尽管安装了消息,并且从python REPL加载正常,并且明确包含在setup.py和py2app命令行调用中。

这是完整的追溯:

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

事情是,我只在第一个地方包含'消息',因为当我尝试运行我的应用程序(没有提到'消息'时),py2app控制台告诉我没有这样的模块。我甚至不确定是什么要求它 - 我当然不会,并且在手动启动时一切正常。再看一下控制台似乎是werkzeug,但当我尝试明确地包含它时(我认为烧瓶会自动执行),仍然无法找到消息。

我最好的猜测是,这是一个多蟒蛇/虚拟环境的事情,但我对此知之甚少,而且它似乎是一个黑暗而不祥的兔子洞,对py2app没有更深入的了解。

非常感谢,

1 个答案:

答案 0 :(得分:0)

模块'flask','jinja2','message'是仅.py文件还是包含 itit .py文件的完整软件包?

尝试:

setup(py_modules=['flask', 'jinja2', 'message']

如果它们是您创建并从“ Glutton.py”调用的.py模块