Trusted answers to developer questions

How to activate virtualenv windows

Get the Learn to Code Starter Pack

Break into tech with the logic & computer science skills you’d learn in a bootcamp or university — at a fraction of the cost. Educative's hand-on curriculum is perfect for new learners hoping to launch a career.

virtualenv is a tool used to create isolated Python environments.

To begin, install pip(python package installer). python3 usually comes with pip installed, however, sometimes the command prompt (cmd) might not recognize it. When this occurs, you may get the error, “pip: command not found.” In this situation, download get-pip.py and make sure the file is saved to the Desktop.

Next, open the command prompt at Desktop to execute get-pip.py by typing:

python3 get-pip.py

Now, pip should work system wide.

Setting up virtualenv

In the command prompt, enter:

pip install virtualenv

Next, open the command prompt in the directory of the project you are working on.

cd project_path
virtualenv env

Now, we activate the env file. This can be done by activating the activate script in the Scripts folder. The following command creates an activate.bat batch file after activation.

\path\to\env\Scripts\activate

This creates an activate.bat batch file after activation.

C:\Users\computer_username\venv\Scripts\activate.bat

This file path is just an example. In reality, it could vary from user to user.

Terminal
Terminal

RELATED TAGS

python

CONTRIBUTOR

Sarvech Qadir
Copyright ©2024 Educative, Inc. All rights reserved
Did you find this helpful?