3

I'm using a computation server where I have no root privileges, so in order to be able to install whatever libraries I want, I created a virtualenv with --system-site-packages for python 2.6.

Then, inside the virtual environment, I installed numpy version 1.8.2 because the system numpy version (1.3.0) is too old for my requirements:

numpy - 1.3.0 - active development (/usr/lib64/python2.6/site-packages)

numpy - 1.8.2 - non-active

I need the --system-site-packages option because I'm using some system libraries that I cannot install in the virtual environment. However I am not able to tell the virtual environment to use the most recent version of numpy.

Does anyone know how to select version 1.8.2 in the virtual environment? I tried with pkg_resources.require('numpy==1.8.2') but I got the error:

pkg_resources.VersionConflict: (numpy 1.3.0 (/usr/lib64/python2.6/site-packages), Requirement.parse('numpy==1.8.2'))

Is there some way of telling the virtual environment to look for libraries in the virtual virt2/lib64/python2.6/site-packages folder before looking in the system's /usr/lib64/python2.6/site-packages folder?

ali_m
  • 71,714
  • 23
  • 223
  • 298
Luis
  • 31
  • 1
  • 1
    Possible using pip, I am not sure about pkg_resources, http://stackoverflow.com/questions/12079607/make-virtualenv-inherit-specific-packages-from-your-global-site-packages – DhruvPathak Aug 19 '14 at 10:18
  • How exactly did you install numpy inside your virtualenv? You should just be able to `~$ pip install -I numpy==1.8.2` (the `-I` might be needed in order to tell `pip` to ignore the system-wide numpy that's already installed). What output do you get when you call `~$ python -c "import numpy; print numpy.__version__, numpy.__file__"` from within your virtualenv? – ali_m Aug 19 '14 at 14:40

1 Answers1

0

It is likely that ou have been bitten by issue #461 and currently(as of August-2014) you CANNOT upgrade any system-inherited package because virtualenv's paths are ordered AFTER any system-paths within sys.path.

Your workaround it to move the (usually) last sys-path entry one position above:

  • Re-ordering sys.path with python-code., For instance, assuming that the index of your virtualenv's site-packages is the last one, you have to make sure that the following code runs before any other code:

    import sys; sys.path.insert(0, sys.path.pop(-1))
    
  • modify similarly your PYTHONPATH environment-variable before executing python-interpreter (see question #10738919 and ).

Community
  • 1
  • 1
ankostis
  • 8,579
  • 3
  • 47
  • 61