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).
I'm building my setup.py with:
python setup.py py2app --packages=jinja2,flask,message
And my setup.py looks like:
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.
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. 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.
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.
Many thanks,