14383 shaares
5331 private links
5331 private links
sudo apt install python3.6 python3-pip
Next, we’re going to upgrade pip because OCD and install virtualenv and virtualenvwrapper.
sudo -H pip3 install --upgrade pip
sudo -H pip3 install virtualenv virtualenvwrapper
Edit your ~/.bashrc
export WORKON_HOME=$HOME/.virtualenvs # Environments stored here
export PROJECT_HOME=/mnt/c/Users/<username>/Code # Path to your Python projects
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3.6 # Make Python3 the default
source /usr/local/bin/virtualenvwrapper.sh # Engage!
Finally load all the goodies with ''''source ~/.bashrc.''''
Bonus
I like workon <environment name> to dump me in the project directory. To do this, add the following to ~/.virtualenv/postactivate
PROJ_NAME=$(basename $VIRTUAL_ENV)
cd $PROJECT_HOME/$PROJ_NAME