venv
venv
Every python project should have its own virtual environment such that requirements can be managed on a project basis rather than polluting the global pip
.
Initialize a virtual environment
python -m venv myvenv
Next, activate it:
source myvenv/bin/activate
Now, one can, e.g., install requirements from a requirements.txt
file, which then only will be available within the virtual environment myvenv
.
pip install -r requirements.txt
That way, the global pip
stays nice and clean.
Finally, deactivate the virtual environment by deactivate
to return to the usual shell.
Last updated