11/29: django pip with virtualenv
If you are using pip install somepackage
, and it is not going into your virtualenv, perhaps you are tripping over the same thing I did.
I had activated the virtualenv with /usr/local/pythonenv/DJANGO-1-1/bin/activate, and (DJANGO-1-1) was appearing in the shell prompt. which pip
showed /usr/local/pythonenv/DJANGO-1-1/bin/pip. python
followed by
import sys for p in sys.path: print p
showed that the system site-packages directories were not being included. So why was the python package being installed to /usr/local/python2.6/site-packages???
Well, the pythonenvs had been installed as root. I was actually running sudo pip install somepackage
and that meant I was losing the virtualenv environment (which sets some environment variables that don’t survive the sudo to root transition).
So the solution was to run [UPDATED 2011/01/04]
sudo /usr/local/pythonenv/DJANGO-1-1/bin/pip install -E /usr/local/pythonenv/DJANGO-1-1/ somepackage
and indeed I threw in the --download-cache
option to cut down on the download time (although I subscribe to DSL, my download times are closer to dial-up speeds) for subsequent installs into the DJANGO-1-0 and DJANGO-1-2 virtual envs.