简体   繁体   中英

Cannot find the updated python module

I have installed the latest version of Python numpy module but when i tried to look for the version of the new numpy module, it still shows me the old version.

sudo pip install 'numpy==1.9.0'

python -c "import numpy; print numpy.__version__"
1.8.2

Here are my Python and pip versions

python --version
Python 2.7.6

pip --version
pip 8.1.2

Am i missing something here?

The version of pip you are using is not associated with the version of Python you're using. pip is installing NumPy into the miniconda distribution (BTW, are you aware that the latest version of NumPy is 1.11.3?), whereas your Python binary is reading its site-packages from elsewhere. To determine this, run

python

at the command prompt, then once in the interpreter run

>>> import sys
>>> print(sys.executable)
>>> from pprint import pprint as pp # makes reading the results easier
>>> pp(sys.path)

sys.executable will tell you which python binary you're running, and the sys.path list will tell you from where Python is importing its packages.

All this being said, you need to point your pip script to the version of Python you're actually using. The easiest way (IMO) is to download get-pip.py , then run either

python get-pip.py

(after changing to the download directory) or

sudo python get-pip.py

depending on whether you're an admin or not. This will install the latest version of pip (currently 9.0.1) and associate it with the version of Python that was used to call the script.

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