Mac 10.6 Universal Binary scipy: cephes / specfun symbol "_aswfa_" not found

I cannot get scipy to work in 32-bit mode when compiled as i386 / x86_64 universal binary code and run on my 64-bit 10.6.2 MacPro1,1.

My python setup

Using this answer, I built a 32/64 bit universal python 2.6.4 binary with the intention of using the arch command to select between architectures. (I managed to create several universal binaries from several libraries that I wanted to use lipo.) All this works. Then I installed scipy in accordance with the instructions in the hyperjeff article , only with more modern numpy (1.4.0) and skipping bits about a short movement to the side during the installation of scipy.

Now everything except scipy seems to work as far as I can tell, and I can really choose between 32 and 64 bit mode using arch -i386 python and arch -x86_64 python .

Mistake

Scipy complains about 32-bit mode:

 $ arch -x86_64 python -c "import scipy.interpolate; print 'success'" success $ arch -i386 python -c "import scipy.interpolate; print 'success'" Traceback (most recent call last): File "<string>", line 1, in <module> File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/scipy/interpolate/__init__.py", line 7, in <module> from interpolate import * File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/scipy/interpolate/interpolate.py", line 13, in <module> import scipy.special as spec File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/scipy/special/__init__.py", line 8, in <module> from basic import * File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/scipy/special/basic.py", line 8, in <module> from _cephes import * ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/scipy/special/_cephes.so, 2): Symbol not found: _aswfa_ Referenced from: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/scipy/special/_cephes.so Expected in: flat namespace in /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/scipy/special/_cephes.so 

Attempt to track problem

It looks like scipy.interpolate is importing something called _cephes , which is looking for a character called _aswfa_ but cannot find it in 32-bit mode. Looking through scipy source, I find the ASWFA routine in specfun.f. The only scipy file with a similar name is specfun.so, but both _cephes.so seem to be universal binaries:

 $ cd /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/scipy/special/ $ file _cephes.so specfun.so _cephes.so: Mach-O universal binary with 2 architectures _cephes.so (for architecture i386): Mach-O bundle i386 _cephes.so (for architecture x86_64): Mach-O 64-bit bundle x86_64 specfun.so: Mach-O universal binary with 2 architectures specfun.so (for architecture i386): Mach-O bundle i386 specfun.so (for architecture x86_64): Mach-O 64-bit bundle x86_64 

Hog. I am stuck. I can try, but did not understand how to enable the specfun.so compilation myself, somehow.

I would suggest that scipy is not broken on all 32-bit machines, so I think that something is wrong with the way I installed it, but I can’t understand what.

I really do not expect a complete answer, given my unique (?) Setting, but if anyone has any clues that could point me in the right direction, they would be greatly appreciated.

(change) More about the questions:

I am using gfortran (GNU Fortran from GCC 4.2.1 Apple Inc. build 5646).

Python 2.6.4 was installed more or less:

 cd /tmp curl -O http://www.python.org/ftp/python/2.6.4/Python-2.6.4.tar.bz2 tar xf Python-2.6.4.tar.bz2 cd Python-2.6.4 # Now replace buggy pythonw.c file with one that supports the "arch" command: curl http://bugs.python.org/file14949/pythonw.c | sed s/2.7/2.6/ > Mac/Tools/pythonw.c ./configure --enable-framework=/Library/Frameworks --enable-universalsdk=/ --with-universal-archs=intel make -j4 sudo make frameworkinstall 

Scipy 0.7.1 has been installed pretty much as described here , but it comes down to a simple sudo python setup.py install .

It would be true that the symbol is undefined in the i386 architecture if you look at the _cephes library with nm , as David Kurnapo suggested:

 $ nm -arch x86_64 /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/scipy/special/_cephes.so | grep _aswfa_ 00000000000d4950 T _aswfa_ 000000000011e4b0 d _oblate_aswfa_data 000000000011e510 d _oblate_aswfa_nocv_data (snip) $ nm -arch i386 /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/scipy/special/_cephes.so | grep _aswfa_ U _aswfa_ 0002e96c d _oblate_aswfa_data 0002e99c d _oblate_aswfa_nocv_data (snip) 

however, I cannot yet explain its absence.

+6
python scipy architecture osx-snow-leopard universal-binary
source share
2 answers

Have you tried using scipy compiled using macports?

 sudo port install scipy +universal 

(of course, you should have the rest of the chain, python , py26-numpy compiled with the same option)

I get:

 $ arch -x86_64 /opt/local/bin/python -c "import scipy.interpolate; print 'success'" success $ arch -i386 /opt/local/bin/python -c "import scipy.interpolate; print 'success'" success 

you can use the settings and knowledge that macro developers used to create their own compilation.

+3
source share

How did you install scipy, for which version of python and with which fortran compiler?

You can also check that the missing character is indeed in both arches (I don’t remember which side the function is on, but you can easily find ti yourself using the nm / otool combination).

+1
source share

All Articles