Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python points to global installation even after virtualenv activation

It's a bit weird, I have activated the virtual environment python still points to the global installation.

$ which python
/usr/bin/python

$ source ~/virtualenv/bin/activate
(virtualenv)$ which python
/usr/bin/python 

What am I missing?

like image 840
Krishna Bharadwaj Avatar asked Feb 05 '15 07:02

Krishna Bharadwaj


People also ask

Do I have to activate VENV every time?

You don't specifically need to activate an environment; activation just prepends the virtual environment's binary directory to your path, so that “python” invokes the virtual environment's Python interpreter and you can run installed scripts without having to use their full path.

How do I know if my virtual environment is activated Orcode?

Restart VSCode and click on the interpreter version on the left-bottom corner. Now, you will be able to see the virtual environment python interpreter in the interpreter list.


1 Answers

Thanks to pointers from @Barun Sharma, I could fix this.

Initially I had created a virtual environment in the directory ~/projectname. Later I decided to move it to under ~/virtualenv. This would result in a stale path ~/projectname in $PATH variable. Updating VIRTUAL_ENV to the latest path in /bin/activate solved the problem.

like image 170
Krishna Bharadwaj Avatar answered Oct 02 '22 23:10

Krishna Bharadwaj