Post

Install/Configure VirtualEnvWrapper

This post is from 2020 and may be out of date. On Ubuntu 23.04 and later, pip3 install outside a virtual environment is blocked (PEP 668); use sudo apt install virtualenvwrapper and source /usr/share/virtualenvwrapper/virtualenvwrapper.sh instead.

from readthedocs, Stack Overflow (1), Stack Overflow (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 1. Install
pip3 install virtualenvwrapper

# 2. Create a directory for your environments
$ mkdir ~/py-envs/

# 3. Add a path to where virtual environments will be stored to your profile
$ echo "export WORKON_HOME=~/py-envs" >> ~/.profile

# 4. Add a path to the correct python symlink or executable to your profile
$ echo "export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3" >> ~/.profile

# 5. You need to run this shell script at the start of every session, 
#    so add it to your profile
$ echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.profile

# 6. Source
$ source ~/.profile

# 7. Commands are available now, e.g., to make and load an environment:
$ mkvirtualenv env1
$ workon env1
(env1)$ 
This post is licensed under CC BY 4.0 by the author.