5

I am attempting to update/upgrade my NumPy, but am failing. I think I might have multiple versions of NumPy installed in different directories, but python by default imports an old one. Any help?

Here's where my Python is:

Gonzo-vs-Kitties:~ brian$ which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python

Here's the version that Python imports:

Gonzo-vs-Kitties:~ brian$ python
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> print numpy.__version__
1.5.1
>>>

Now I use easy_install to upgrade NumPy:

Gonzo-vs-Kitties:~ brian$ sudo easy_install --upgrade numpy
Searching for numpy
Reading http://pypi.python.org/simple/numpy/
Reading http://numpy.scipy.org
Reading http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=175103
Reading http://numeric.scipy.org
Best match: numpy 1.6.2
Processing numpy-1.6.2-py2.7-macosx-10.7-intel.egg
numpy 1.6.2 is already the active version in easy-install.pth
Installing f2py script to /usr/local/bin

Using /Library/Python/2.7/site-packages/numpy-1.6.2-py2.7-macosx-10.7-intel.egg
Processing dependencies for numpy
Finished processing dependencies for numpy

Even after I upgrade, NumPy is still the old version:

>>> import numpy
>>> print numpy.__version__
1.5.1
>>>

This is my sys.path:

>>> print sys.path
['', '/Library/Python/2.7/site-packages/nose-1.2.1-py2.7.egg', '/Library/Python/2.7/site-packages/virtualenv-1.8.2-py2.7.egg', '/Users/brian/Code/trac/genshi-trunk', '/Users/brian/Code/trac/trac-trunk', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Library/Python/2.7/site-packages/pip-1.2.1-py2.7.egg', '/Library/Python/2.7/site-packages/numpy-1.6.2-py2.7-macosx-10.7-intel.egg', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages', '/Library/Python/2.7/site-packages']

Any ideas?

BMS
  • 215
  • 3
  • 8
  • Usually for things like that, virtualenv is amazing. You can just create a new venv and install new version of anything without worrying that stuff is imported properly, conflicts, etc. And if anything goes wrong, its much easier to troubleshoot. – miki725 Oct 15 '12 at 05:02

1 Answers1

4

Check the path of your numpy package:

import numpy
print numpy.__path__

And check whether it is the one you just installed.

waitingkuo
  • 89,478
  • 28
  • 112
  • 118
  • It is not the one I just installed. the __path__ attribute points to '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy' Ideas on how to address this? – BMS Oct 15 '12 at 04:53
  • Remove the old version of numpy, or upgrade it – waitingkuo Oct 15 '12 at 05:34
  • 1
    When I use pip and/or easy_install to in install,it removes my newer 1.6.2 NumPy and completely ignores the 1.5.1 NumPy. How do I uninstall a version that the uninstaller can't see? – BMS Oct 15 '12 at 15:00
  • 2
    Depends on how you installed them. Or you can go to that directory and remove it directly. – waitingkuo Oct 15 '12 at 15:07
  • 1
    I manually removed the directory where the old NumPy was stored. Python now finds the updated NumPy. Thank you very much. – BMS Oct 15 '12 at 16:28
  • 2
    Note that it is a **VERY BAD IDEA** to overwrite the `/System/...` numpy, as it may be used internally by the OS. The safest by far is to install numpy locally (ie, from the sources, `python setup.py install --user`), and update your PYTHONPATH so that it captures your local numpy before the system one (just do `PYTHONPATH=$HOME/.local/lib/python2.x/site-packages:$PYTHONPATH`) – Pierre GM Oct 22 '12 at 10:27