Python virtual environment

How to quickly create a virtual env for Python on Linux:

  1. sudo apt install python3-pip to be sure that pip is installed.

  2. pip3 install virtualenv to install virtualenv package.

  3. mkdir ~/some_project to create a folder some_project in home directory.

  4. cd ~/some_project to enter that folder.

  5. virtualenv -p python3 venv to create a virtual environment directory venv with Python 3 as the interpreter.

  6. source ~/some_project/venv/bin/activate to activate the virtual environment


Other commands:

deactivate to stop the virtual env.
rm ~/some_project to remove the virtual env.

More detailed info: https://virtualenv.pypa.io/en/stable/userguide/