Virtualenv: How to make sure MY environment used all the time

software development

#1

I recently started with virtualenv and was trying to install my own packages like PIL etc.

I wanted to know what do I need to do to make sure once I activate the environment, it remains activated or at least it is used, instead of the system python.

Thanks in advance.


#2

I had a similar problem trying to install Django 1.3 in a virtualenv. I got it to override the loaded modules (modifying the passenger script and PYTHONPATH).

I can’t tell you how to override the system default python (take a look at the Python page at dreamhost wiki), but for the python packages, it’s simple, just add the paths BEFORE the system ones, like this:

sys.path.insert(0,’/home/USERNAME/virtualenv/lib/python2.5/site-packages/PACKAGE_NAME’)

That will put the dir in the first place of the list therefore loading it instead of the system default. The good thing is that if you break the package for some reason, it will fallback in the system package.


#3

Thanks a lot. That did help.