batuman batuman - 1 month ago 28
Python Question

Upgrading numpy version

I have three numpy in my system. They are at /usr/local/lib/python2.7/dist-packages/numpy, ~/anaconda2/lib/python2.7/site-packages/numpy and ~/tensorflow/lib/python2.7/site-packages/numpy. tensorflow is Python virtual environment.

I checked the versions. How I checked is inside numpy has version.py file and can see as

# THIS FILE IS GENERATED FROM NUMPY SETUP.PY
#
# To compare versions robustly, use `numpy.lib.NumpyVersion`
short_version = '1.11.2'
version = '1.11.2'
full_version = '1.11.2'
git_revision = 'bb6e3dc30016b89bf154f7d7fce4248e760bd40f'
release = True

if not release:
version = full_version


All have 1.11 version.
But when I go inside tensorflow virtual environment, python version is shown 1.8.

How to check which numpy version it is referring to?

How to upgrade?

(tensorflow)xxx@xxx-HP-Z420-Workstation:/$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.version.version
'1.8.2'
>>>

Answer

check the path using

import numpy
print numpy.__path__

and manually delete it using rm / sudo rm if operation is not permitted. try, running the command below, it will overwrite to the latest numpy path.

sudo easy_install numpy

Now, try to import tensorflow as tf it should find the right numpy. it's advisable to create a new virtual env.