Trying to create a virtualenv in python and activate it

You’ve installed it correctly. The command you gave: virtualenv ENV will create a folder called ENV and place the installation inside it.

The dictionary will be created in the path specified in the shell.

IE if when running it said :

C:\Users\UserName>virualenv ENV

the ENV folder will be placed int C:\Users\UserName.

This is absolutely fine. Note that you don’t have to call it ENV all the time though.


To activate you would need to navigate (in the shell using the command cd) to the location where virtualenv is installed. Once there you enter

ENV\Scripts\activate 

activate is a batch script that will change your terminal to have (ENV) (or whatever filename you choose at the beginning of the shell path. When you see this it tells you it has been activated.


To stop the virtual environment you need to use deactivate. This can be used in the same way. IE like this:

ENV\Scripts\deactivate 

Just in case your using PowerShell and not Command Prompt:

On PowerShell there are execution policies. This means there are additional actions that apply:

Before starting allow all scripts on the system must be digitally signed to execute. You can do it like this:

Set-ExecutionPolicy AllSigned

When you create your virtual environment you use:

virtualenv .\ENV

(notice the .\ instead of just the folder name)

Next to run use the similar (but different) command:

 .\ENV\scripts\activate

(once again notice the .\)

When prompted you will need to accept the execution just enter Y. It has been activated.

The virtualenv instructions are here for complete reference

Leave a Comment