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?
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 ).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.