Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run uwsgi with virtualenv

I'm currently developing my first real python flask project and am about to set up the build server to deploy the "Latest Build" which is built on every check-in.

I have set up a startup script where I start the application using uwsgi and this part is working fine. I have recently also started using virtualenv and by doing so the packages installed are added to my project under projectname\flask\Lib\site-packages.

I'm using nginx as the web server and the config looks like this:

location / { try_files $uri @graderbuild; } location @graderbuild {     include uwsgi_params;     uwsgi_param UWSGI_CHDIR /usr/local/grader/build;     uwsgi_param UWSGI_PYHOME /usr/local/grader/build;     uwsgi_pass 127.0.0.1:3031; } 

I'm starting uwsgi using this:

exec /usr/local/bin/uwsgi --master --socket 127.0.0.1:3031     --wsgi-file restserver.py --callable app --processes 4 --die-on-term     --threads 2 >> /var/log/grader-build.log 2>&1 

Now to where I know if I'm doing it right... currently I am deploying the entire folder to the build server. I don't want to install global python modules just to get my build to work. Right or wrong?

The error I get currently is:

ImportError: No module named flask_wtf 

If I'm right, how do I configure the setup to use the virtualenv site-packages? My preferred location would be in the startup script and not in the nginx config.

like image 744
Asken Avatar asked Aug 24 '13 10:08

Asken


1 Answers

Use -H to set virtualenv to python path.

uwsgi -H /path/to/your/virtualenv  

http://uwsgi-docs.readthedocs.org/en/latest/Options.html#virtualenv

like image 103
iMom0 Avatar answered Sep 22 '22 12:09

iMom0