3

I was trying to install python and its scientific libraries on a clean install of Mountain Lion, with Xcode and its command line tools.

I installed homebrew and, through it, a fresh python 2.7 as I didn't want to mess up with the one Apple provides. I also installed gfortran always via homebrew.

Then I install Numpy from its source, using the flag to build it using gfortran. I did this because if I pip install it then the scipy installation will fail.

With installed, I tested it through bumpy.test('full') and it says OK.

At this point I tried to install scipy, both using pip or from source. The result is the same, it installs but i get a HUGE number of failures and one error when I test it using scipy.test(). Any idea of how to fix this?

The reported error is

ERROR: test_logm_consistency (test_matfuncs.TestExpM)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/scipy/linalg/tests/test_matfuncs.py", line 124, in test_logm_consistency
    assert_array_almost_equal(expm(logm(a)), a)
  File "/usr/local/lib/python2.7/site-packages/scipy/linalg/matfuncs.py", line 453, in logm
    errest = norm(expm(F)-A,1) / norm(A,1)
  File "/usr/local/lib/python2.7/site-packages/scipy/linalg/matfuncs.py", line 49, in expm
    A_L1 = norm(A,1)
  File "/usr/local/lib/python2.7/site-packages/scipy/linalg/misc.py", line 12, in norm
    a = np.asarray_chkfinite(a)
  File "/usr/local/lib/python2.7/site-packages/numpy/lib/function_base.py", line 590, in asarray_chkfinite
    "array must not contain infs or NaNs")
ValueError: array must not contain infs or NaNs

The failures are instead related to boas, basic, dot, asum, nrm2, arpack.

Any idea of how to fix this?

purpleshift
  • 170
  • 1
  • 7
  • 1
    See: http://stackoverflow.com/questions/12092306/how-to-install-scipy-with-pip-on-mac-mountain-lion-os-x-v10-8/14315132#14315132 . I recommend using Samueljohn's 'taps' to install scipy. – Anton I. Sipos Jan 28 '13 at 03:36

1 Answers1

2

My advice is to always set up python computing enviroments (especially with finicky packages like scipy and numpy) in a virtualenv. virtualenv is a tool that allows you to set up and switch in and out of isolated python environments, so that installing and changing things in one environment doesn't mess with the others.

EDIT: another reason to use virtualenv is that if you screw everything up, you haven't messed up your global system configuration and you can just delete the virtualenv and start over from scratch to fix it. I also recommend virtualenvwrapper which is basically just some sugar that makes virtualenv more intuitive and faster to use.

Also to address your actual question: I believe that you still have to use the development branch of scipy in order for it to compile successfully on OSX 10.8. I followed the instructions here pretty much exactly and everything worked fine.

James Porter
  • 1,853
  • 2
  • 17
  • 30
  • Hi James, thanks for answering. I tried also to setup everything inside an isolated virtual environment but eventually nose reported even more errors. If you use virtualenv and the developer version of scipy you have that you can install both numpy and scipy via pip. Outside the virtualenv you have to compile the former, otherwise the installation of scipy will fail. – purpleshift Dec 03 '12 at 20:29