Happy to help When I forked your repo and deployed to sharing, this is the error I saw in the logs:
[manager] Python dependencies were installed from /app/webtools-fitbit4food/requirements.txt using pip.
[manager] Processed dependencies!
2021-07-08 05:05:41.679 An update to the [server] config option section was detected. To have these changes be reflected, please restart streamlit.
Traceback (most recent call last):
File "reinforcement_engine.py", line 3, in <module>
from flask import Flask, request, make_response
ModuleNotFoundError: No module named 'flask'
Another log message indicated that the
flask package was successfully installed from the requirements file:
Successfully installed Inflect-5.3.0 MarkupSafe-2.0.1 Send2Trash-1.7.1 Werkzeug-2.0.1 altair-4.1.0 argon2-cffi-20.1.0 astor-0.8.1 async-generator-1.10 attrs-21.2.0 backcall-0.2.0 base58-2.1.0 bleach-3.3.0 blinker-1.4 cachetools-4.2.2 certifi-2021.5.30 cffi-1.14.5 chardet-4.0.0 click-8.0.1 debugpy-1.3.0 decorator-5.0.9 defusedxml-0.7.1 entrypoints-0.3 flask-2.0.1 flask-cors-3.0.10
While it initially seems contradictory, there’s a straightforward explanation:
The packages in your requirements file are installed in a virtual environment. The Python binary used in this virtual env is found at
In line 584 of your app, you run
python reinforcement_engine.py via a subprocess. This Python binary is not the one used in the virtual env where your packages, including
flask, are installed.
Change line 584 to the following:
subprocess.Popen(['/home/appuser/venv/bin/python', 'reinforcement_engine.py'], close_fds=True)
Reboot your app
Once you make the change you should not see the flask related import error: