I create a virtual environment; let's say test_venv, and I activate it. All successful.
HOWEVER, the path of the Python Interpreter doesn't not change. I have illustrated the situation below.
For clarification, the python path SHOULD BE ~/Desktop/test_venv/bin/python
.
>>> python3 -m venv Desktop/test_venv
>>> source Desktop/test_venv/bin/activate
(test_venv) >>> which python
/usr/bin/python
This is what you should do if you don't want to create a new virtual environment:
In venv/bin
folder there are 3 files that store your venv path explicitly
and if the path is wrong they take the normal python path so you should change the path there to your new path.
change: set -gx VIRTUAL_ENV "what/ever/path/you/need"
in activate.fish
change: VIRTUAL_ENV="what/ever/path/you/need"
in activate
change: setenv VIRTUAL_ENV "what/ever/path/you/need"
in activate.csh
Note #1:
the path is to /venv
and not to /venv/bin
Note #2:
If you reached this page it means that you are probably not following Python's best practice for a project structure.
If you were, the process of creating a new virtual environment was just a matter of one command line.
Please consider using one of the following methods:
requirements.txt
to your project - not recommended.setup.py
script - for real projects.Thanks to Khalaimov Dmitrii, I didn't thought it was because I moved the folder.