User Tools

Site Tools



Info / Resources



Sample Pages

Quick Navigation


Python Virtual Environment

Q: Admin can you install package X?

Q: Can you remove package Y which is conflicting with X and meanwhile update package Z?

Q: On second thought, Can I do anything I want without having to ask?

Hopefully you'll like the third question the best. The short answer is NO (in general) , however within python realms the answer is a big YES and saves quite a lot of developer's time as well as sysadmins. So with that in mind let's see what we need:

Basically the idea is for you to have your copy of python, which you have COMPLETE power of. This python is not different than the regular python, but it's just a virtual one, so that anyone can have as many python environments as needed without needing to change the system for all users.

virtualenv is a tool to create isolated Python environments. virtualenv creates a folder which contains all the necessary executables to use the packages that a Python project would need. Just what you need, a standalone python which is yours and you have the control over it..! Thus you don’t need any super privileges to install libraries or better yet you can have multiple python environments with different settings and packages. The steps to get and use this tool is quite easy:

Install it using PIP (Skip this step in COR@L Machines)

$ pip install virtualenv


Create a folder to contain the files regarding to virtual python instance . Running the second command creates the mentioned folder named “vpython”.

$ mkdir myPython && cd myPython
$ virtualenv vpython
  1. To start using the new python


$ source vpython/bin/activate

From now on any python runs or installations using pip will be done corresponding to the python copy located at vpython. This is what the (vpython) means in your bash prompt. Feel free to install any packages you like without any problems.!

Going back to Normal

After your work is done you can simply deactivate the active environment and get back to normal boring settings.!

$ deactivate
Contact Alireza [sey212] for more help regarding this page.
setup/pythonvirtual.txt · Last modified: 2016/12/13 10:23 by sertalpbilal