1

I've got a Flask app in Docker. I'm trying to run it like:

uwsgi --socket 0.0.0.0:80 --plugins python3 --protocol http --module app.app:app -p 2 --enable-threads

uWSGI starts, initializes Python (I've checked if it might be wrong interpreter issue, but it is initializing the right one) and then does something like this:

*** Operational MODE: preforking ***
Traceback (most recent call last):
  File "./app/app.py", line 1, in <module>
    from flask import Flask
ModuleNotFoundError: No module named 'flask'
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***

Catch here is that it is definitely installed. If I bash into container and make pip freeze, it shows up. If I run Python shell, I can import it without problems. If I try to start uwsgi again manually (killing the previous to free the port), I get the same issue. If I just run python app/app.py, there is no such issue.

Since my main package (app) was named the same as created Flask app I renamed Flasks's app (as in this question), but looks like this wasn't the problem. What else can cause this issue? This is how my project is structured, if it helps:

├── Dockerfile
├── LICENSE
├── README.md
├── app
│   ├── __init__.py
│   ├── submodule1
│   │   ├── __init__.py
│   │   └── somefile1.py
│   ├── app.py
│   ├── config.py
│   ├── submodule2
│   │   ├── __init__.py
│   │   ├── somefile2.py
│   ├── submodule3
│   │   ├── __init__.py
│   │   └── somefile3.py
├── docker-compose.yml
├── requirements.txt
└── startup.sh <-- this is where uwsgi is started
keddad
  • 1,398
  • 3
  • 14
  • 35

0 Answers0