Managing Python Virtual Environments
Python offers a virtual environment module which lets us install project based requirements instead of maintain all requirements in a global scope.
Although its common for developers to utilise wrapper scripts such as virtualenvwrapper to manage venvs in a global location rather than in the project scope.
Usage - Native venv
The python module comes as part of the standard library. Its standard practise to create virtual environments in a venv subfolder. This is often ignored from VCS and should not be committed as its unique to the individual system.
Create a new environment
python -m venv venv # Create a new virtual environment, if a 'venv' subfolderEnable the environment
source venv/bin/activateDisable the environment
deactivateUsage - virtualenvwrapper
virtualenvwrapper helps manage multiple virtual environments within a global level rather than scattering venv directories across all your projects source code.
Create a environment
mkvirtualenv myprojectEnable the environment
workon myprojectDeactivate the environment
deactivateList environments
lsvirtualenvDelete environment
rmvirtualenv myprojectUsage - Poetry
Poetry offers more feature fledged dependency management, including its own way to activate virtual environments.
Refer to the separate page for Poetry notes
