This repository has been archived on 2023-07-05. You can view files and clone it, but cannot push or open issues/pull-requests.
notes/Terminal Tips/Commands + Settings/Languages/Python/tools/Environments/Venv/Venv.md

30 lines
1.3 KiB
Markdown
Raw Normal View History

2023-07-05 03:05:42 +00:00
Apparently venv is the way that Python suggests ([Pythons `venv` module](https://docs.python.org/3/library/venv.html) ) to create virtual environments. This module is part of Pythons standard library, and its 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, youre 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
```