Setup and use Python Venv in Python Applications

wesleybertipaglia

Wesley Bertipaglia

Posted on April 11, 2024

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
💖 💪 🙅 🚩
wesleybertipaglia
Wesley Bertipaglia

Posted on April 11, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related