Search code examples
flaskmoduledependenciespyinstallerpy2app

how does py2app add custom modules


I try to create from a python script using flask framework a standalone mac app with py2app. The application uses the framework pyfladesk for render website within a desktop window. On testing everything works fine, but as soon as I try to deploy the app with py2app , the folders get bundled and the app is created. But as soon as I start the app, it halts. Looking in terminal it shows a ModuleNotFoundError. The module pyfladesk is not found. How do I add 3 party modules to a py2app project. I tried the same procedure with pyinstaller as well with the same result.

Note: the module was added with pip3 and is located inside the venv of the given folder. enter image description here


Solution

  • Solved the issue, it turns out, py2app does not rely on the dependencies from venv, but rather on the installed one. Solution: pip3 install pyfladesk and all other used packages update dependency search path in setup.py:

    OPTIONS = {'argv_emulation': True, 'packages': ['requests', 'jinja2', 'pyfladesk'] }