Issue
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
Solution
Please make sure to read Note #2.
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:
- add a
requirements.txt
to your project - for very small projects. - implement an
setup.py
script - for real projects. - use a tool like Poetry - just like the latter though somewhat user-friendlier for some tasks.
Thanks you Khalaimov Dmitrii, I didn't thought it was because I moved the folder.
Answered By - ניר Answer Checked By - Marilyn (WPSolving Volunteer)