Ticket #308 (new defect)
obspy.taup import fails (gfortran underscoring issue?)
| Reported by: | jkmacc | Owned by: | |
|---|---|---|---|
| Priority: | major | Component: | ObsPy library |
| Keywords: | taup, gfortran | Cc: |
Description
Hi, everyone. I installed obspy.taup into the Enthought Python Distro 32 bit, and don't recall having any problems with the install. When I call taup, however, I get the following error (below). I don't have any problems using taup in the EPD 64 bit distribution. I'm using OS X 10.6.8. In looking at seteup.py, there seems to be a "-fno-underscoring" flag that should be passed along. Perhaps this isn't being passed? I apologize if this has been covered already; it didn't look like the previous issue with gfortran.
Thanks in advance!
Best, Jon
In [5]: from obspy.taup import taup
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
/Volumes/jkmacc/projects/TienShan/db/<ipython-input-5-faae2965f0ae> in <module>()
----> 1 from obspy.taup import taup
/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/site-packages/obspy.taup-0.0.3-py2.7-macosx-10.5-i386.egg/obspy/taup/taup.py in <module>()
2
3 from obspy.taup import __path__
----> 4 from util import flibtaup as lib
5 import ctypes as C
6 import math
/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/site-packages/obspy.taup-0.0.3-py2.7-macosx-10.5-i386.egg/obspy/taup/util.py in <module>()
31 if not flibtaup:
32 msg = 'Could not load shared library for obspy.taup.\n\n %s' % (e)
---> 33 raise ImportError(msg)
ImportError: Could not load shared library for obspy.taup.
dlopen(/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/site-packages/obspy.taup-0.0.3-py2.7-macosx-10.5-i386.egg/obspy/taup/lib/libtaup.so, 6): Symbol not found: __gfortran_compare_string
Referenced from: /Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/site-packages/obspy.taup-0.0.3-py2.7-macosx-10.5-i386.egg/obspy/taup/lib/libtaup.so
Expected in: flat namespace
in /Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/site-packages/obspy.taup-0.0.3-py2.7-macosx-10.5-i386.egg/obspy/taup/lib/libtaup.so
Attachments
Change History
comment:2 Changed 3 months ago by megies
I'm not sure if this was the problem but you could try to install obspy.taup again and try it. If not it might help to post the install log here (any compiler messages/errors..?).
EDIT: Ah no, that's definitely not what was going wrong here. So could you post the install/compiler log?
best, Tobias
comment:3 Changed 3 months ago by jkmacc
Tobias, thanks for thinking about it. I rebuilt taup and below is my screen output. After installing, I can import taup now, but I get a different error when I try to use it (see end)...
jkmacc% python setup.py build running build running build_py creating build/lib.macosx-10.5-i386-2.7 creating build/lib.macosx-10.5-i386-2.7/obspy copying obspy/__init__.py -> build/lib.macosx-10.5-i386-2.7/obspy creating build/lib.macosx-10.5-i386-2.7/obspy/taup copying obspy/taup/__init__.py -> build/lib.macosx-10.5-i386-2.7/obspy/taup copying obspy/taup/taup.py -> build/lib.macosx-10.5-i386-2.7/obspy/taup copying obspy/taup/util.py -> build/lib.macosx-10.5-i386-2.7/obspy/taup creating build/lib.macosx-10.5-i386-2.7/obspy/taup/tests copying obspy/taup/tests/__init__.py -> build/lib.macosx-10.5-i386-2.7/obspy/taup/tests copying obspy/taup/tests/test_taup.py -> build/lib.macosx-10.5-i386-2.7/obspy/taup/tests running egg_info writing requirements to obspy.taup.egg-info/requires.txt writing obspy.taup.egg-info/PKG-INFO writing namespace_packages to obspy.taup.egg-info/namespace_packages.txt writing top-level names to obspy.taup.egg-info/top_level.txt writing dependency_links to obspy.taup.egg-info/dependency_links.txt reading manifest file 'obspy.taup.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no files found matching 'docs/api/*' writing manifest file 'obspy.taup.egg-info/SOURCES.txt' copying obspy/taup/LICENSE.txt -> build/lib.macosx-10.5-i386-2.7/obspy/taup copying obspy/taup/README.txt -> build/lib.macosx-10.5-i386-2.7/obspy/taup copying obspy/taup/VERSION.txt -> build/lib.macosx-10.5-i386-2.7/obspy/taup creating build/lib.macosx-10.5-i386-2.7/obspy/taup/src copying obspy/taup/src/emdlv.f -> build/lib.macosx-10.5-i386-2.7/obspy/taup/src copying obspy/taup/src/iaspei-tau.tgz -> build/lib.macosx-10.5-i386-2.7/obspy/taup/src copying obspy/taup/src/libtau.f -> build/lib.macosx-10.5-i386-2.7/obspy/taup/src copying obspy/taup/src/ttimes_subrout.f -> build/lib.macosx-10.5-i386-2.7/obspy/taup/src copying obspy/taup/src/ttlim.inc -> build/lib.macosx-10.5-i386-2.7/obspy/taup/src creating build/lib.macosx-10.5-i386-2.7/obspy/taup/tables copying obspy/taup/tables/ak135.hed -> build/lib.macosx-10.5-i386-2.7/obspy/taup/tables copying obspy/taup/tables/ak135.tbl -> build/lib.macosx-10.5-i386-2.7/obspy/taup/tables copying obspy/taup/tables/iasp91.hed -> build/lib.macosx-10.5-i386-2.7/obspy/taup/tables copying obspy/taup/tables/iasp91.tbl -> build/lib.macosx-10.5-i386-2.7/obspy/taup/tables creating build/lib.macosx-10.5-i386-2.7/obspy/taup/tests/data copying obspy/taup/tests/data/sample_ttimes_ak135.lst -> build/lib.macosx-10.5-i386-2.7/obspy/taup/tests/data copying obspy/taup/tests/data/sample_ttimes_iasp91.lst -> build/lib.macosx-10.5-i386-2.7/obspy/taup/tests/data running build_ext building 'libtaup' extension creating build/temp.macosx-10.5-i386-2.7 creating build/temp.macosx-10.5-i386-2.7/obspy creating build/temp.macosx-10.5-i386-2.7/obspy/taup creating build/temp.macosx-10.5-i386-2.7/obspy/taup/src gfortran obspy/taup/src/emdlv.f -o build/temp.macosx-10.5-i386-2.7/obspy/taup/src/emdlv.o -c -fno-underscoring gfortran obspy/taup/src/libtau.f -o build/temp.macosx-10.5-i386-2.7/obspy/taup/src/libtau.o -c -fno-underscoring gfortran obspy/taup/src/ttimes_subrout.f -o build/temp.macosx-10.5-i386-2.7/obspy/taup/src/ttimes_subrout.o -c -fno-underscoring creating build/lib.macosx-10.5-i386-2.7/obspy/taup/lib gcc -bundle -undefined dynamic_lookup -g -arch i386 build/temp.macosx-10.5-i386-2.7/obspy/taup/src/emdlv.o build/temp.macosx-10.5-i386-2.7/obspy/taup/src/libtau.o build/temp.macosx-10.5-i386-2.7/obspy/taup/src/ttimes_subrout.o -lgfortran -o build/lib.macosx-10.5-i386-2.7/obspy/taup/lib/libtaup.so ld: warning: in build/temp.macosx-10.5-i386-2.7/obspy/taup/src/emdlv.o, file was built for unsupported file format which is not the architecture being linked (i386) ld: warning: in build/temp.macosx-10.5-i386-2.7/obspy/taup/src/libtau.o, file was built for unsupported file format which is not the architecture being linked (i386) ld: warning: in build/temp.macosx-10.5-i386-2.7/obspy/taup/src/ttimes_subrout.o, file was built for unsupported file format which is not the architecture being linked (i386)
In [1]: from obspy.taup import taup
In [2]: taup.getTravelTimes(78.8, 100, model='ak135')
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/Users/jkmacc/<ipython-input-2-c3db94c548c5> in <module>()
----> 1 taup.getTravelTimes(78.8, 100, model='ak135')
/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/site-packages/obspy.taup-0.0.3-py2.7-macosx-10.5-i386.egg/obspy/taup/taup.pyc in getTravelTimes(delta, depth, model)
70 flags = ['F_CONTIGUOUS', 'ALIGNED', 'WRITEABLE']
71
---> 72 lib.ttimes(C.byref(delta), C.byref(depth), modnam,
73 phase_names,
74 tt.ctypes.data_as(C.POINTER(C.c_float)),
/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/ctypes/__init__.pyc in __getattr__(self, name)
364 if name.startswith('__') and name.endswith('__'):
365 raise AttributeError(name)
--> 366 func = self.__getitem__(name)
367 setattr(self, name, func)
368 return func
/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/ctypes/__init__.pyc in __getitem__(self, name_or_ordinal)
369
370 def __getitem__(self, name_or_ordinal):
--> 371 func = self._FuncPtr((name_or_ordinal, self))
372 if not isinstance(name_or_ordinal, (int, long)):
373 func.__name__ = name_or_ordinal
AttributeError: dlsym(0x5100d60, ttimes): symbol not found
I get see ttimes in build/temp.macosx-10.5-i386-2.7/obspy/taup/src/ttimes_subrout.o (build/lib.macosx-10.5-i386-2.7/obspy/taup/lib/libtaup.so has almost no symbols in it). It looks like the final gcc build call failed.
jkmacc% nm temp.macosx-10.5-i386-2.7/obspy/taup/src/ttimes_subrout.o | grep ttimes 0000000000000000 T _ttimes 00000000000010a0 S _ttimes.eh
comment:4 Changed 3 months ago by krischer
Hi Jon,
all symbols need to be in libtaup.so because that is the file actually called by ctypes.
Can you try to execute the following command in the src subdirectory?
gfortran -fno-underscoring -arch i386 -dynamiclib -lgfortran emdlv.f libtau.f ttimes_subrout.f -o libtaup.so
This will create a 32bit shared library which should contain all necessary symbols. Copying this to the lib subdirectory and replacing its libtaup.so should also work fine.
If this works than its either a issue with your compiler setup or with obspy.taup's setup.py.
Thanks for your help!
Lion
comment:5 Changed 3 months ago by jkmacc
That did it!
Didn't work:
gcc -bundle -undefined dynamic_lookup -g -arch i386 emdlv.o libtau.o ttimes_subrout.o -lgfortran -o libtaup.so
Worked:
gfortran -fno-underscoring -arch i386 -dynamiclib -lgfortran emdlv.f libtau.f ttimes_subrout.f -o libtaup.so
I don't know why gcc instead of gfortran was called in my initial install, but it seems that the latter did the trick. Thanks again!
comment:6 Changed 3 months ago by krischer
Hey.
Glad it worked. Unfortunately that does not really solve the problem because setup.py should also be able to correctly compile it. Not sure how to solve this. Your command should, in theory, also work. In your case setup.py uses gfortran to compile the source code to object files and then simply uses gcc to link them together. I'll look into it and maybe I can force setup.py into using a specific command to link the files.
Best wishes.
Lion

In [3005/obspy]: