DEV Community

Cover image for Setting up a Python Virtual Environment in Windows
Sujitkumar Singh
Sujitkumar Singh

Posted on

Setting up a Python Virtual Environment in Windows


Python, like most other modern programming languages, has its own unique way of downloading, storing, and resolving packages (or modules). While this has its advantages, there were some interesting decisions made about package storage and resolution, which has lead to some problems—particularly with how and where packages are stored.

What is a virtual environment?

A virtual environment is a tool that helps to keep dependencies required by different projects separate by creating isolated Python virtual environments for them. This is one of the most important tools that most of the Python developers use.


  1. Python3 installed

Let's Get Started


1.Installing Virtualenv

Open command prompt and type in the following command:

pip install virtualenv

2.Create a Virtualenv

Go to the project directory say path/to/project:

cd path/to/project

Once inside the project folder run to create a virtualenv named 'myvenv':

virtualenv myvenv

3.Start the Virtualenv

In the same directory type the following to activate the virtual environment:


Hurray! We are in our virtual environment!


Now you can install packages relevant to a particular project which would be confined to this virtual environment only!

4.To deactivate the Virtualenv run the following command:


Note: Whenever you are running any packages make sure the venv is active

Top comments (0)