Installing python virtualenv

From IT-help UiB
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Information.gif Please give us a


Virtualenv creates an isolated space for a project, together with a copy of all you need to run a python program. The virtualenv tool can f.i. be used to solve problems that arise from having multiple python projects with different/incompatible demands to the setup of a given system.

Installing virtualenv:

[user@hostname ~]$ sudo apt-get install python-virtualenv

Creating an isolated space for a given project, with pip included:

[user@hostname ~]$ cd path/to/all/my/projects
[user@hostname allmyprojects]$ virtualenv myproject_env
[user@hostname allmyprojects]$ cd myproject_env
[user@hostname myproject_env]$ source bin/activate

Adding python packages to the prosject:

[user@hostname myproject_env]$ pip install pythonpackage
  • The packages will be stored in myproject_env/. They are only available to the given project.

To complete/close work on a project:

(myproject_env)[user@hostname myproject_env]$ deactivate