How to create isolated Python virtual environment?

By Gulshan Saini
Published in Python
August 18, 2020
1 min read

Python 3.3+ comes with the venv library, providing support for creating lightweight “virtual environments” with their own site directories, optionally isolated from system site directories.

Creating virtual environment

To create an isolated virtual environment for Python type python -m venv <name_of_virtual_env>

python -m venv local_env

This will create a local_env/ directory, including your Python environment. Any Python libraries you install while your virtual environment is active will go into the local_env/lib/python3.8/site-packages directory.

Activate virtual environment

After creating the virtual environment, next step is to activate your virtual environment, which can be done as follows

source local_env/bin/activate

The shell prompt will include the name of the active virtual environment enclosed in parentheses, as follows:

(local_env) ➜  projects

De-activate virtual environment

To de-activate virtual environment type deactivate command and press Enter key.


Previous Article
What is the max HTTP header size in NodeJS server?
Gulshan Saini

Gulshan Saini

Fullstack Developer



Subscribe to our newsletter!

We'll send you the best of our blog just once a month. We promise.

Quick Links

Contact UsBrowserCSSPythonPuppeteer

Social Media