Isolate Python installations with virtualenv

virtualenv is a tool used to create isolated environments for Python.

When it comes to working with Python, especially during application development, there are situations that demand working with multiple version of libraries, modules, and even Python itself. Thus it rises a very common issue - how to make Python projects with different and often conflicting requirements to coexist on the same machine. It can be resolved by using a virtual environment for every project.

virtualenv is a tool used to create isolated environments for Python. There you can install packages without interfering with the other virtualenvs or with the Python's system packages. Python modules generally are installed globally. But virtual environment allows storing every project locally and maintaining the dependencies there. This way with virtualenv you can add and modify Python modules without access to the global installation.

An environment in this case is a directory (folder) containing everything that a Python project needs to run in an organised, isolated fashion. There are several ways to install virtualenv on your computer: either using the source tarball, pip or easy_install. Initiating a virtualenv automatically installs its own pip and Python interpreter, as well as setuptools (or optionally distribute). pip, for instance, enables creating a list of dependencies which belongs to a single project and easy recovery of said dependencies using a requirements file.

With virtualenv you receive more than a fresh, isolated environment for a Python project. This piece of software is very useful for testing. It allows to test applications with different sets of libraries and their versions. virtualenv provides easy application packaging and portability across systems. It allows downloading packages without requiring admin/sudo privileges.

virtualenv is the easiest way to configure a custom Python environment. It ensures that your global site-packages directory is manageable and clean. For more information read virtualenv documentation or visit PyPi.

Connect with our experts Let's talk