Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 588 Vote(s) - 3.51 Average
  • 1
  • 2
  • 3
  • 4
  • 5
No module named flask while running uWSGI

#1
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!


Reply

#2
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.
Reply

#3
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.
Reply

#4
I faced similar problem and found the reason that if we have a module installed in a virtual environment(Flask in this case) we may need to add --virtualenv path in addition to the basic instructions needed to run a Flask app using uWSGI

So the instruction according the uWSGI document would be:

uwsgi --http-socket :3031 --plugin python --wsgi-file myflaskapp.py --callable app --virtualenv /path_to_virtualenv


Reply

#5
You can just add one line into you .ini file:

home=/your/virtual/env/path
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through