Virtualenv uses wrong python, even though it is first in $PATH Virtualenv uses wrong python, even though it is first in $PATH linux linux

Virtualenv uses wrong python, even though it is first in $PATH


My problem was that i recently moved my project with virtualenv to another location, due to this activate script had wrong VIRTUAL_ENV path.

$ cat path_to_your_env/bin/activate... # some declarationsVIRTUAL_ENV="/path_to_your_env/bin/python"  # <-- THIS LINEexport VIRTUAL_ENV... # some declarations

To fix this, just update VIRTUAL_ENV in activate script.

Also you maybe need to fix first line of your bin/pip to link to real python path.


As tdelaney suggested in the comments, I ran alias and found that I had previously aliased python to /usr/bin/python3.5 in my .bashrc.

I removed that alias from my .bashrc, ran unalias python, and source ~/.bashrc and the problem was solved.


If you don't get the program that which says you should get, you need to look higher up the chain than the platform executor. Shells typically have a way to alias commands and on most unixy shells you can just enter alias to see which commands have been remapped. Then its just a matter of going to the config files for your shell and removing the alias.

Sometimes people alias python to try to sort out which python they should be using. But there are usually other, better ways. On my linux machine, for example, python3 is in the path but is a symlink to the real python I am using.

td@mintyfresh ~ $ which python3/usr/bin/python3td@mintyfresh ~ $ ls -l /usr/bin/python3lrwxrwxrwx 1 root root 9 Feb 17  2016 /usr/bin/python3 -> python3.4td@mintyfresh ~ $ 

This is nice because non-shell programs running python get the same one I do and virtual environments work naturally.