26 lines
1.8 KiB
Markdown
26 lines
1.8 KiB
Markdown
|
### The Virtualenv [Project](https://realpython.com/python-virtual-environments-a-primer/#the-virtualenv-project "Permanent link")
|
|||
|
|
|||
|
|
|||
|
[Virtualenv](https://virtualenv.pypa.io/en/latest/) is a tool that was specifically made for creating isolated Python environments. It’s been a long-time favorite within the Python community and precedes the built-in `venv` module.
|
|||
|
|
|||
|
Official docs found [here](https://virtualenv.pypa.io/en/latest/installation.html).
|
|||
|
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](https://virtualenv.pypa.io/en/latest/user_guide.html#python-discovery) 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 you’re 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](https://virtualenv.pypa.io/en/latest/user_guide.html#programmatic-api) that allows you to describe virtual environments without creating them.
|
|||
|
|
|||
|
After [installing `virtualenv`](https://virtualenv.pypa.io/en/latest/installation.html) on your system, you can create and activate a new virtual environment similarly to how you do it using `venv`:
|