Cannot find the updated python module

733 views Asked by At

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?

1

There are 1 answers

1
MattDMo On BEST ANSWER

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.