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?
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With