Virtualenv loses context

rhythmicdevil at rhythmicdevil at
Wed Dec 19 15:14:54 CET 2012

I am somewhat new to Python and virtualenv. I have setup a virtualenv with no site packages under the assumption that all 3rd party packages will be installed into the site-packages directory for the virtualenv. Another assumption I have about virtualenv is that it's completely self contained.

When I first setup the virtualenv, install my packages and then install my application both of those assumptions seem to be correct. However, at some point I start getting ImportErrors. The be clear, I tested the application and it was all working correctly, the ImportErrors seem to show up at some random point that I cannot reproduce. 

I have a requirements file that I made with 'pip freeze'. I try to use this to reinstall the packages but I get errors saying that I cannot install to the location. The location is the global site-packages directory on my system. I have the virtualenv activated while installing so I dont know why this is happening.

Due to something about Centos6 I cant install M2Crypto using pip and have to do it manually. This gives me the same types of errors:

(botnet_etl)[swright at localhost M2Crypto]$ ./ install
running install
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

    [Errno 13] Permission denied: '/usr/lib64/python2.6/site-packages/test-easy-inst

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:


Perhaps your account does not have write access to this directory?  If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account.  If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment

For information on other options, you may wish to consult the
documentation at:

Please make the appropriate changes for your system and try again.

The only fix I have managed for this problem so far is to reinstall the entire virtualenv from scratch. This works fine for a while and I have to repeat the process. I would think that I was doing something wrong if the ImportErrors showed up every time I attempt to run the app but the fact that they show up later leads me to believe something funky is going on.

Os = Centos6
Python = 2.6.6


More information about the Python-list mailing list