Installing & using Python virtualenv

virtualenv, as the name suggests, creates virtual Python environments. If you’re familiar with server virtualisation, virtualenv acts in a similar fashion to virtual machines in that the environments share the same physical hardware, but they’re completely separated from one another.

virtualenv is very useful for when you’re working on multiple projects or using applications that require different versions of the same module. In this post I’ll demonstrate how to install and usage of virtualenv on Windows, though the process is similar for Linux too.

If you haven’t already, install virtualenv like so:

Next, create a directory to store your virtualenv(s), and then create one. In the example below, my virtualenv is called test_env:

Next, change to the virtualenv\Scripts directory and issue the activate command:

Once you have done this, your prompt will be prefixed with the name of your environment, e.g  (test_env). This let’s you know that you’re now in a completely separate environment to all of your other environments, including your original Python installation.

If you’d like to exit out of your environment, issue the deactivate command:


As always, if you have any questions or have a topic that you would like me to discuss, please feel free to post a comment at the bottom of this blog entry, e-mail at, or drop me a message on Twitter (@OzNetNerd).

Note: This website is my personal blog. The opinions expressed in this blog are my own and not those of my employer.