DEV Community

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

Posted on

4 2

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

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay