简体   繁体   中英

Python path: why can't pip see latest version of numpy

Working inside a virtualenv, I'm trying to install scikit-image, but it fails, telling me that I need a newer (or any) version of numpy.

$ sudo pip install -U scikit-image
...
ImportError: You need `numpy` version 1.6 or later.
----------------------------------------
Command python setup.py egg_info failed with error code 1 in /Users/aps/Dropbox/experiments/build/scikit-image

I don't understand this, because from Python, numpy 1.7 is already on my path.

$ python 
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.__version__
'1.7.1'

What is going on - why can't the system installing scikit-image see the newest version of numpy? And how can I fix this?

The path to numpy already seems to be in my ~/.bash_profile :

>>> numpy.__path__
['/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy']
>>> exit()
$ vi ~/.bash_profile
...
export PYTHONPATH=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages:$PYTHONPATH

UPDATE:

numpy version 1.7 is also in the su path:

$ sudo python 
Password:
Python 2.7.5 (default, Aug  1 2013, 00:59:40) 
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.__version__
'1.7.1'

You need to make sure that all those packages are available within the virtualenv itself. Did you try running pip freeze after sourcing bin/activate ? Using the virtualenv package, the only library that comes "preinstalled" by default is distribute , and all other dependencies must be manually added. With venv (built into py3k) all of your system libraries should be available directly. Which are you using?

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM