30 lines
1.3 KiB
Markdown
30 lines
1.3 KiB
Markdown
|
Apparently venv is the way that Python suggests ([Python’s `venv` module](https://docs.python.org/3/library/venv.html) ) to create virtual environments. This module is part of Python’s standard library, and it’s the officially recommended way to create virtual environments since Python 3.5.
|
|||
|
|
|||
|
**Note:** There are other great third-party tools for creating virtual environments, such as [conda](https://realpython.com/python-virtual-environments-a-primer/#the-conda-package-and-environment-manager) and [virtualenv](https://realpython.com/python-virtual-environments-a-primer/#the-virtualenv-project). Any of these tools can help you set up a Python virtual environment.
|
|||
|
|
|||
|
For basic usage, `venv` is an excellent choice because it already comes packaged with your Python installation. With that in mind, you’re ready to create your first virtual environment.
|
|||
|
|
|||
|
---
|
|||
|
# Create a virtual environment
|
|||
|
To make a new virtual environment with `venv` simply:
|
|||
|
|
|||
|
1. head to your project folder or make one
|
|||
|
```
|
|||
|
mkdir project_folder # this makes a project folder
|
|||
|
cd project_folder # head to your project folder
|
|||
|
```
|
|||
|
|
|||
|
2. create a new venv environment
|
|||
|
```
|
|||
|
python -m venv env_name
|
|||
|
```
|
|||
|
|
|||
|
3. activate the environment
|
|||
|
```
|
|||
|
source env_name/bin/activate
|
|||
|
```
|
|||
|
|
|||
|
4. deactivate when done
|
|||
|
```
|
|||
|
deactivate
|
|||
|
```
|