Home > Blockchain >  Why there are two python versions in a virtual environment?
Why there are two python versions in a virtual environment?

Time:03-04

I have created a virtual environment using anaconda in VS. When the environment is active. I check the version using python --version, it gives the following output Python 3.9.9, whereas when I use which python and check the version from the path /usr/bin/python --version I get a different version Python 2.7.18. Why is that happening, and which version does the environment use?

CodePudding user response:

Once your virtual environment is activated the python command will use the python version from your venv (located in path/to/.venv/bin/python). which python and /usr/bin/python forces the use of the python version installed in /usr/bin/python which in your case seems to be version 2.7.18. If you want to change your default Python version (the one thats used with python without a venv being active) you can use sudo ln -s /usr/bin/python /usr/bin/python3.9.

  • Related