virtualenv
virtualenv is a tool to create isolated Python environments. virtualenv creates a folder which contains all the necessary executables to use the packages that a Python project would need.
Check
virtualenv --version
Usage
To activate a configured virtual environment (see Install below)...
cd ~/mypython
source venv/bin/activate
Run any python related commands, including pip. Any pip installs will remain local to this virtual environment.
When you are done...
deactivate
Install
virtualenv
pip3 install virtualenv
NOTE: You will need to make sure ~/.local/bin is in your PATHCreate a project folder for your python projects...
mkdir ~/mypython
cd ~/mypython
virtualenv -p /usr/bin/python3.6 venv
NOTE: If you omit the -p option, the virtual environment will inherit your current Python versionNOTE: venv is a commonly recognised virtual environment name and is often readily available in ignore files (eg: .gitignore’)NOTE: when your virtual environment is active the string (venv) will be prepended to your promptvirtualenvwrapper
pip3 install virtualenvwrapper
export WORKON_HOME=~/mypython
source ~/mypython/venv/bin/virtualenvwrapper.sh
Usage
workon venv # Work in the venv virtual environment
deactivate # Stop working in the virtual environment
Other commands...
mkvirtualenv newvenv # Make a new virtual environment
rmvirtualenv newvenv # Remove a virtual environment