Reputation: 26467
I've noticed strange behavior of virtualenv installed on my local machine. This is what I've been doing:
tomasz@laptop:~/Development/Python$ virtualenv nac-env
New python executable in nac-env/bin/python
Installing Setuptools...................................................................................................................................................................................................................................done.
Installing Pip.....................................................................................................................................................................................................................................................................................................................................done.
tomasz@laptop:~/Development/Python$ cd nac-env
tomasz@laptop:~/Development/Python/nac-env$ source ./bin/activate
(nac-env)tomasz@laptop:~/Development/Python/nac-env$ which python
/usr/bin/python
(nac-env)tomasz@laptop:~/Development/Python/nac-env$ which pip
/usr/bin/pip
(nac-env)tomasz@laptop:~/Development/Python/nac-env$ which easy_install
/usr/local/bin/easy_install
(nac-env)tomasz@laptop:~/Development/Python/nac-env$ echo $PYTHONPATH
/usr/lib/python2.7/site-packages:/usr/lib/python2.7/dist-packages
(nac-env)tomasz@laptop:~/Development/Python/nac-env$ deactivate
tomasz@laptop:~/Development/Python/nac-env$
As the nettuts screencast says (http://www.youtube.com/watch?v=IX-v6yvGYFg, 6:55), python
, pip
and easy_install
executables should point to files inside the virtual environment and not to /usr/bin/...
stuff. If the $PYTHONPATH
sysvar is set incorrectly, I think that my installation doesn't work as expected... Does anyone know what's going wrong?
PS I have installed virtualenv globally on my local machine some time ago. Probably it was intalled through pip
or sth like that.
Upvotes: 2
Views: 1289
Reputation: 11
I had this happen to me. Did you change your project path?
When I first created the virtual environment, I used ~/src/my_project/venv
but later changed it to ~/projects/my_project/venv
. When I ran the activate scripts, it was using the old path. To fix this, I did a substitution on all of the scripts in the activate directory with the new path and python
, pip
, etc. were now sourced from the virtual environment.
Upvotes: 1
Reputation: 26467
Well, I made myself sure this behavior I had in fact is not normal. I've uninstalled existing virtualenv
and re-installed it from pip
and now everything works perfectly:
tomasz@laptop:~/Development/Python/foo$ source bin/activate
(foo)tomasz@laptop:~/Development/Python/foo$ which python
/home/tomasz/Development/Python/foo/bin/python
(foo)tomasz@laptop:~/Development/Python/foo$ which pip
/home/tomasz/Development/Python/foo/bin/pip
(foo)tomasz@laptop:~/Development/Python/foo$ which easy_install
/home/tomasz/Development/Python/foo/bin/easy_install
(foo)tomasz@laptop:~/Development/Python/foo$ echo $PYTHONPATH
/usr/lib/python2.7/site-packages:/usr/lib/python2.7/dist-packages
Upvotes: 1