I have a very simple flask app (myflaskapp.py):
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return "<span style='color:red'>I am app 1</span>"
If I run:
uwsgi --http-socket :3031 --plugin python --wsgi-file myflaskapp.py --callable app
I get the following output:
Traceback (most recent call last):
File "myflaskapp.py", line 1, in <module>
from flask import Flask
ImportError: No module named flask
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
and I don't understand why. I have flask installed (pip install flask). If I run ipython and import flask it also works there. Any ideas? Thanks!
In the end what worked for me was adding -H /path/to/virtualenv to the uWSGI command:
uwsgi --http-socket :3031 --plugin python --wsgi-file myflaskapp.py --callable app -H /path/to/virtualenv
I also had different Python versions in the virtualenv and for uWSGI. I'm still investigating if this could cause any problems.
I ran into same problem once, as there was some version conflict
then instead of using pip to install uwsgi I did it by my package manager On ubuntu machine,
sudo apt-get install uwsgi
Also check and run myflaskapp.py without uwsgi that is by using app.run() in your code
*Note : That will be by werkzeug server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With