5.10. Virtualenv

Virtualenv is a virtual environment for Python. It is a recommended way of developing using Python because you can have a specific version of Python installed for a project along with other required packages, just for that project. You can then have other projects on the same computer each with their own different package versions and requirements. You use pip to add packages to a specific virtual environment and they stay at that version unless you upgrade which reduces the risk of accidentally introducing incompatibilities.

5.10.1. Create

Note

The Python version installed will depend on your distro default.

Python 3 specifically:

cd ~
mkdir PROJECT_FOLDER
cd PROJECT_FOLDER
virtualenv -p python3 venv

Note

Add the venv folder to .gitignore if you are use version control.

5.10.2. Activate

If you log off or close the terminal you need to activate the virtualenv:

cd ~
cd proj_name
source venv/bin/activate