hirschme
hirschme

Reputation: 894

Why does python import a lower version of Numpy?

I installed numpy with pip, version 1.15

pip show numpy
python -m pip show numpy

Name: numpy
Version: 1.15.0

However when I import numpy with python, I get version 1.7.1

>>> import numpy
>>> numpy.version.version
'1.7.1'

Where is this numpy coming from and how can I disable it?

I checked on all folders from the sys.path, and erased folders of numpy version 1.7.1

import sys sys.path ['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/home/hirsch/.local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PILcompat', '/usr/lib/python2.7/dist-packages/gtk-2.0']

But that did not solve this issue.

>>> which pip
/home/hirsch/.local/bin/pip

>>> which python
/usr/bin/python

Upvotes: 1

Views: 1360

Answers (1)

Benoît P
Benoît P

Reputation: 3265

Use python -m pip instead of pip, you likely have multiple pythons installed.

python -m pip show numpy

Name: numpy
Version: 1.7.1

which pip will tell you the path of your unwanted install

An other possible cause is that you have two Numpy's installed on the same python, in which case uninstall both and reinstall.

The thing is, if you have multiple versions of numpy and import it, python imports the first one it finds. You might want to look int virtual environment if you need to keep multiple versions of numpy (in every case, you have to uninstall older numpy's that are in conflict).

Upvotes: 4

Related Questions