1

(I looked at many answers on here but similar questions were not answered or didn't address my question).

I use numpy + scipy + matplotlib on Mac-OSX 10.8.5. I have numpy 1.6.1 on my machine and using python 2.7.5 in /System/Library/Frameworks/Python.framework/Versions/2.7/. I've been running with that configuration for several months running from Idle or the command line.

I just upgraded to matplotlib 1.3.1 from the .dmg file at Sourceforge. The install worked fine and I can see the correct version in matplotlib.__version__. However, I cannot use it because it claims I need numpy 1.7 or higher. So I downloaded the numpy-1.8.0 dmg file from Sourceforge and installed it using the Mac installer. The installer claims to have done it correctly, but numpy.__version__ is still 1.6.1!!! I've done the installation multiple times (each time successfully according to the Mac installer) with the same result.

I had no problem upgrading matplotlib to 1.3.1 and scipy to 0.13 using their respective .dmg files at Sourceforge. I don't see why numpy should not install the same way. I must have upgraded it the same way in the past, but I can't remember.

I run Python from Idle as well as from the command line and don't want to go to some other distribution like Macports, etc. I've been using Python this way for 4 years and don't understand why numpy is not being updated. Thanks for any help.

Paul Avery
  • 117
  • 1
  • 1
  • 8
  • Correction. My python version runs from `/Library/Frameworks/Python.framework/Versions/2.7/bin/python`. When I look at the site-packages directory, I can see the numpy directory and that many of the files have been updated as of today. There is also a `numpy-1.8.0-py2.7.egg-info/` directory. – Paul Avery Nov 08 '13 at 16:56
  • What do you get if you run `numpy.__file__` and `matplotlib.__file__` in the python terminal? – askewchan Nov 08 '13 at 17:48
  • Hi, you have identified something important: numpy: `/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/__init__.pyc` matplotlib: `/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/__init__.pyc` scipy: `/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/__init__.pyc` So numpy is updating a different directory than matplotlib and scipy! Do you have a fix for that? Thanks, in the meantime for identifying the issue. – Paul Avery Nov 08 '13 at 21:48
  • I'm not sure how dangerous it is, but I would try copying `/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/nump‌​y/` to `/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/`, but to be safer, first move, if it exists `/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/` to `/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy_old/` – askewchan Nov 08 '13 at 21:54
  • So the issue is two different python installations, (1) the original "apple" one in `/System/Library/...` (which I don't use) vs (2) the user version in `/Library/...` which has the 2.7.5 version installed from python.org. The apple installer for numpy updates the original Apple installation while all others update the user-installed one. Is there a way to easily fix the numpy installation? – Paul Avery Nov 08 '13 at 22:01
  • Ah, missed your comment. I will try that. Thanks. – Paul Avery Nov 08 '13 at 22:02
  • I wrote a better description in the answer. – askewchan Nov 08 '13 at 22:03
  • It's not going to work. The directory '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/nump‌​‌​y/' was not updated (all dates are from a few months ago), but `/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/n‌​umpy/` was updated today. Yet when I run python (from shell or Idle) it still finds numpy in the first location. – Paul Avery Nov 08 '13 at 22:13

1 Answers1

1

Three solutions, one is the one given in my comment, but an easier one might be to change your PYTHONPATH. On the command line:

export PYTHONPATH=/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/:$PYTHONPATH

To make the change permanent, put that line in your

~/.bashrc

file.


From my comment:
I'm not sure how dangerous it is, but to just move the installation to be with your others, you could try

mv /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/n‌​umpy/ /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/n‌​umpy_old/
cp /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/nump‌​‌​y/ /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/n‌​umpy/

Finally, you could try using pip to install numpy. To see where pip is installed, type this in terminal:

which pip

If it's where you want it to be (/Library/...), then all you have to do is

pip install numpy
askewchan
  • 45,161
  • 17
  • 118
  • 134
  • Actually, I ran pip before I posted the question, but forgot to mention that. pip is indeed located in `/Library/Frameworks/Python.framework/Versions/2.7/bin/pip`. However, when I ran it, I had to type `pip install numpy --upgrade` because pip found an earlier version. I don't think that the PYTHONPATH solution will help when running from Idle, which I do quite frequently when debugging. – Paul Avery Nov 08 '13 at 22:23
  • It seems you'll have to look at `import sys; sys.path` and see where it's looking for numpy. Modifying `sys.path` is a bit tricky though. – askewchan Nov 08 '13 at 22:34
  • Sigh... I tried installing numpy-1.7.1 afterwards. Now when I run python from the shell I get `numpy.__version__ = 1.7.1`. Good. Idle still claims that numpy is 1.6.1. Bad. Then I installed matplotlob-1.3.1 to see if I can run my program from the shell correctly. But when I run my program from the shell, python complains that matplotlib.pyplot is incompatible with my installed numpy, which it claims is version 6, even though when I ran python from the shell it claimed that numpy was 1.7.1. I am thoroughly confused. – Paul Avery Nov 08 '13 at 22:40
  • By 'shell' do you mean the interpreter (what you get when you just type `python` on the terminal), or from terminal, as in `python my_script.py`? Also, from terminal, what do `which python` and `which idle` give you? – askewchan Nov 08 '13 at 22:44
  • Yes, the first non-blank entry in sys.path is `/System/Library/...` with `/Library/...` following a few entries later. I totally don't understand why it is set that way when I've been using the second version since I bought the Mac in July and installed python 2.7.5. This is totally messed up. – Paul Avery Nov 08 '13 at 22:46
  • Yes, I mean the interpreter, when I type python as a shell command. – Paul Avery Nov 08 '13 at 22:47
  • Hold on: I use python myscript.py when I run a program – Paul Avery Nov 08 '13 at 22:48
  • Now when I use the python interpreter, I get `numpy.__version__ = 1.6.1`, instead of 1.7.1. I have no idea why the version reverted to 1.6.1. Running a python script from the shell always gives me 1.6.1. I would consider installing python again if I knew how to start from scratch. This inconsistency in installing and using numpy relative to other installs is terrible . – Paul Avery Nov 08 '13 at 23:04
  • OK, I can see what happened and your comments pointed me to the solution. All my updates, numpy included, updated the `/Library/...` version of python, not touching the Apple-installed original `/System/Library...`. However, the Apple version also had its own version of numpy which was picked because sys.path had `/System/Library` as the first entry. I merely renamed `/numpy` to `/numpy_old` in the `/System/Library` version and that forced the system to look in the new `/Library/...` version of `numpy/` that had been there all along. Thanks very much for your help. – Paul Avery Nov 08 '13 at 23:46
  • I tried to up vote your answer, but my reputation is not high enough to do so. Perhaps you'll get your reward in heaven. :-) – Paul Avery Nov 08 '13 at 23:48