Short time ago, I started with PYTHON and have few applications running. Up to now, I did not take into account, if pip packages have been installed from repository or using pip install.
Actually I’m thinking to clean up in order to use pipx from now on. pip freeze shows 205 packages, pip list additionally:
python3 -m venv venv # make an empty virtualenv in "venv"
# pick your preferred subdir name
./venv/bin/python3 -m pip install ...whatever...
Whenever you invoke ./venv/bin/python3 it runs the Python associated
with the virtual environment you made just here, unique to this project.
This is what Steven meant about “isolated”: a distinct venv per project
with just what you wanted for that project.
Personally, I don’t use the “activate” command (which fiddles your shell
environment), because I only want the venv Python when running the
project code, not for general stuff. So I’ve got a 'dev" command which:
prepends the project Python source tree to $PYTHONPATH
prepends ./venv/bin to $PATH (with the full path to venv)
execs its arguments
So when I want to run the project Python I do something like:
dev python3 ...whatever...
which will find the python3 from the venv.
Typically projects keep their required third party packages in a requirements.txt file; that both documents them and also means you can
reinstall the packages for yourproject in the venv with: