Notepad/enter/Coding Tips (Classical)/Terminal Tips/Languages/Python/tools/Environments/Venv/Virtualenv.md

1.8 KiB
Raw Blame History

Virtualenv is a tool that was specifically made for creating isolated Python environments. Its been a long-time favorite within the Python community and precedes the built-in venv module.

Official docs found here. List all virtual environments installed on your system:

lsvirtualenv

By default, virtualenv creates environments in the $HOME/.virtualenvs directory on Linux and macOS, or in the %USERPROFILE%\Envs directory on Windows. You can use the ls command to list the contents of this directory and see the names of all the virtualenv environments installed on your system.


The package is a superset of venv, which allows you to do everything that you can do using venv, and more. Virtualenv allows you to:

  • Create virtual environments more quickly
  • Discover installed versions of Python without needing to provide the absolute path
  • Upgrade the tool using pip
  • Extend the functionality of the tool yourself

Any of these additional functionalities can come in handy when youre working on your Python projects. You might even want to save a blueprint of your virtualenv in code together with your project to aid reproducibility. Virtualenv has a rich programmatic API that allows you to describe virtual environments without creating them.

After installing virtualenv on your system, you can create and activate a new virtual environment similarly to how you do it using venv: