DEV Community

Cover image for Setup and use Python Venv in Python Applications
Wesley Bertipaglia
Wesley Bertipaglia

Posted on

Setup and use Python Venv in Python Applications

Python Venv is a built-in tool to create and manage lightweight virtual environments.

For more information visit: venv tutorial.

Installation:

Already installed on MacOS and Windows platforms, but needs to be installed on some Linux distros, here is an installation guide for different package managers:



sudo apt install python3-env # using apt
sudo dnf install python3-env # using dnf
sudo pacman -S python3-env # using pacman


Enter fullscreen mode Exit fullscreen mode

Creating a Virtual Environment:



python -m venv <env_name> # Unix-like systems
python -m venv <env_name> # windows


Enter fullscreen mode Exit fullscreen mode

Activating the Virtual Environment:

  • On Unix-like systems (Unix, Linux, or MacOS): ```bash

source /bin/activate


- On Windows:
```bash


<env_name>\Scripts\activate


Enter fullscreen mode Exit fullscreen mode

Deactivating the Virtual Environment:



deactivate


Enter fullscreen mode Exit fullscreen mode

Top comments (0)