Trouble activating virtualenv on server via Fabric Trouble activating virtualenv on server via Fabric django django

Trouble activating virtualenv on server via Fabric


You should call the python version from your virtualenv bin directory, then you will be sure it uses the virtualenv's version of python.

/home/newsapps/sites/mysite/env/bin/python /home/newsapps/sites/mysite/repository/mysite/configs/staging/manage.py collectstatic --noinput -v0


I wouldn't bother with activating the virtualenv, just give the full path to the virtualenv's python interpreter. That will then use the correct PYTHONPATH, etc.


I had the same problem. Couldn't solve it the easy way. So I just used the full path to the python bin file inside the virtualenv. I'm not a pro in Python, but I guess it's the same thing in the end. It goes something like this in my fab file:

PYTHON = '/home/dudus/.virtualenvs/pai/bin/python'PIP = '/home/dudus/.virtualenvs/pai/bin/pip'def update_db():    with cd(REMOTE_DIR + 'application/'):        run('%s ./manage.py syncdb --settings="%s"' %             (PYTHON, SETTINGS)) # syncdb        run('%s ./manage.py migrate --settings="%s"' %             (PYTHON, SETTINGS)) # south migrate