When working with Python, it is generally so that work is done using virtual environments. Install virtualenvwrapper via pip install virtualenvwrapper --user
Add the following snippet to your ~/.bashrc file:
# install virtualenvwrapper using pip install virtualenvwrapper --user
if [ -f $HOME/.local/bin/virtualenvwrapper.sh ]; then
# Locate the global Python where virtualenvwrapper is installed.
if [ "$VIRTUALENVWRAPPER_PYTHON" = "" ]; then
VIRTUALENVWRAPPER_PYTHON="$(command \which python3)"
fi
export WORKON_HOME=$HOME/.virtualenvs
source $HOME/.local/bin/virtualenvwrapper.sh
fi
if [ -d $HOME/.pyenv ]; then
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PATH:$PYENV_ROOT/bin"
fi
You can now manage virtualenvs by running mkvirtualenv name
to create a new virtualenv. Virtualenv then creates a few aliases. You can switch between environs with workon
. Simply type deactivate
as you would on a normal venv to exit back to your normal bash.
Check out virtualenvwrapper