Despite the many stories that I've heard about people having problems installing numpy, scipy, and matplotlib on Mac OS X Lion, I've never had any problem until today. I recently updated my system and attempted to install the latest versions of NumPy and SciPy. The NumPy installation went fine and the test ran as expected, however the scipy installation seems to be incomplete. Every time I try to import scipy.stats I get the following error:
In [1]: import scipy.stats
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-b66176eb2d0a> in <module>()
----> 1 import scipy.stats
/Library/Python/2.7/site-packages/scipy/stats/__init__.py in <module>()
326 """
327
--> 328 from stats import *
329 from distributions import *
330 from rv import *
/Library/Python/2.7/site-packages/scipy/stats/stats.py in <module>()
191 # Scipy imports.
192 from numpy import array, asarray, dot, ma, zeros, sum
--> 193 import scipy.special as special
194 import scipy.linalg as linalg
195 import numpy as np
/Library/Python/2.7/site-packages/scipy/special/__init__.py in <module>()
525 """
526
--> 527 from _ufuncs import *
528 from _ufuncs_cxx import *
529
ImportError: dlopen(/Library/Python/2.7/site-packages/scipy/special/_ufuncs.so, 2): no suitable image found. Did find:
/Library/Python/2.7/site-packages/scipy/special/_ufuncs.so: mach-o, but wrong architecture
I am using the latest version of numpy and scipy off of github. For some reason it looks like the x86_64 version of the _ufuncs.so isn't being built. I've tried every compiler flag I can think of ARCHFLAGS="-arch i386 -arch x86_64" LDFLAGS="-arch i386 -arch x86_64" FFLAGS="-m64 -ff2c"
and no mater what I do I get the same error. Any advice?
UPDATE So I think that I've found the problem, I will follow-up on the scipy distribution list:
Most of the libraries created when scipy builds are universal files meaning that they support both i386 and x86_64. The problem is that the files compiled with gfortran are compiled as i386 only.
> find . -name *.so | xargs -I {} lipo -info {}
Architectures in the fat file: ./build/lib.macosx-10.7-intel-2.7/scipy/cluster/_hierarchy_wrap.so are: i386 x86_64
Architectures in the fat file: ./build/lib.macosx-10.7-intel-2.7/scipy/cluster/_vq.so are: i386 x86_64
Non-fat file: ./build/lib.macosx-10.7-intel-2.7/scipy/fftpack/_fftpack.so is architecture: i386
I've checked my environment and I don't see anything suspicious. As specified on the SciPy Mac OS X page. I only export: CC=gcc-4.2 CXX=g++-4.2 FFLAGS=-ff2c
I just did install on another system and everything worked just fine.