Search code examples
pythondjangoubuntuuwsgipipenv

Right settings for uwsgi.ini file with Django and pipenv


Usually, I don't use pipen and working with virtualenv, virtualenvwrapper and requirements.txt with my django projects. In this case my uwsgi.ini file looks like: [uwsgi]

project = cv-base
uid = cvc
base = /home/%(uid)
chdir = %(base)/%(project)
home = %(base)**/Env**/%(project) <----!!!!!!!
module = %(project).wsgi:application
master = true
processes = 5
socket = /run/uwsgi/%(project).sock
chown-socket = %(uid):www-data
chmod-socket = 660
vacuum = true

Where values home have links to my virtualenv thrue folder Env. But now I cant have this folder, and cant unrestand what to substitute here.

At log file I got an error

 !!! Python Home is not a directory: /home/cvc/Env/cv-base !!!
Jun 26 13:48:55 CV-base uwsgi[12482]: Set PythonHome to /home/cvc/Env/cv-base

Solution

  • You can use pipenv --venv for printing the virtual env directory that is pipenv is using.

    $ mkdir test
    $ cd test
    $ pipenv shell
    …
    $ pipenv --venv
    /home/foobar/.local/share/virtualenvs/a-atLBagCC
    

    So you should use the option virtualenv = /home/foobar/.local/share/virtualenvs/a-atLBagCC in your uwsgi.ini file