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

Introduction

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.

Prerequisites:

  1. Python3 installed

Let's Get Started

Minion

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:

myenv\Scripts\activate

Hurray! We are in our virtual environment!

Hurray

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:

deactivate

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

Top comments (0)