When trying to run my flask application I get the error:
uwsgi no module named site
I created a configuration file as such:
[uwsgi]
socket = 127.0.0.1:8000
processes = 4
virtualenv = /var/www/test/venv
chdir = /var/www/test
module = run
callable = manager
logto = var/www/uwsgi.log
The location of my run.py is /var/www/test/run.py with the following code:
from flask.ext.migrate import Migrate, MigrateCommand
from flask.ext.script import Manager
from app import app, db
if __name__ == "__main__":
migrate = Migrate(app, db)
manager = Manager(app)
manager.add_command('db', MigrateCommand)
manager.run()
Can anyone help me understand where I have gone wrong please? I am running a system wide UWSGI.
EDIT
I installed uwsgi and virtualenv using pip and I have the following versions:
My system wide python version (and the one inside my venv) is: Python 2.7.3
It seems that uWSGI binds the Python 3 runtime during install. Once you've pip installed a version, it uses the cached wheel (hence cached Python version).
If you want to run Flask in production, be sure to use a production-ready web server like Nginx, and let your app be handled by a WSGI application server like Gunicorn.
You don't want use app.run() (or manager.run()) and uwsgi at the same time, because:
So you just need to properly setup uwsgi, something like that should work:
app-name = test
pidfile = /run/uwsgi/%(app-name)/pid
socket = /run/uwsgi/%(app-name)/socket
logto = /var/log/uwsgi/%(app-name).log
log-date = true
processes = 4
plugins = http,python
base = /srv/www/%(app-name)
home = %(base)/venv # http://uwsgi-docs.readthedocs.org/en/latest/Options.html#home-virtualenv-venv-pyhome
pythonpath = %(base)/venv # http://uwsgi-docs.readthedocs.org/en/latest/Options.html#pythonpath-python-path-pp
module = app
callable = app
chdir = %(base)
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