Virtual Environments With virtualenvwrapper for windows

If you are a python developer, you would have faced some situations where you spend hours installing the libraries you need, only to find you have broken some piece of code you have already written. Sometimes certain packages support only some specific version, which may conflict with your other codes.

The solution is to create a virtual environment where you can play around by keeping the packages detached from your code's rest. This post will help you in setting up a virtual environment. These instructions are for Windows.

Let’s first install the python package required.

pip install virtualenvwrapper-win

Run the below command to create a new environment where env_name specifies the name of the environment you want to create.

mkvirtualenv env_name

To activate the environment, use the below command.

workon env_name

After running, make sure the environment name is mentioned before the path, as shown in the image below.

To exit from the environment, use the below command.

deactivate

To list all the environments installed, you can use,

lsvirtualenv

For creating virtual environments in an anaconda and use it inside jupyter, see here.