I’m still installing JModelica. I am now in the annoying “nothing broke during install, but somethings still fail when I use them” phase. I am using the instructions here, and using the example to test if things are working because JModelica doesn’t seem to have a test suite. This is what is happening now:
In [1]: import jmodelica.examples.cstr as cstr
/Library/Python/2.6/site-packages/jpype/_pykeywords.py:18: DeprecationWarning: the sets module is deprecated
import sets
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/Users/alchemyst/ in ()
/usr/local/Python/jmodelica/examples/cstr.py in ()
9 from jmodelica.initialization.ipopt import NLPInitialization
10 from jmodelica.initialization.ipopt import InitializationOptimizer
---> 11 from jmodelica.simulation.sundials import TrajectoryLinearInterpolation
12 from jmodelica.simulation.sundials import SundialsDAESimulator
13 from jmodelica.optimization import ipopt
/usr/local/Python/jmodelica/simulation/sundials.py in ()
14
15 try:
---> 16 from pysundials import cvodes
17 from pysundials import ida
18 from pysundials import nvecserial
/Library/Python/2.6/site-packages/pysundials/cvodes.py in ()
39 import ctypes
40 import sundials_core
---> 41 import nvecserial
42
43 realtype = nvecserial.realtype
/Library/Python/2.6/site-packages/pysundials/nvecserial.py in ()
56 PVector = ctypes.POINTER(_NVector)
57
---> 58 nvecserial.N_VNew_Serial.restype = PVector
59
60 nvecserial.N_VLinearSum_Serial.argtypes = [realtype, PVector, realtype, PVector, PVector]
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ctypes/__init__.pyc in __getattr__(self, name)
356 if name.startswith('__') and name.endswith('__'):
357 raise AttributeError(name)
--> 358 func = self.__getitem__(name)
359 setattr(self, name, func)
360 return func
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ctypes/__init__.pyc in __getitem__(self, name_or_ordinal)
361
362 def __getitem__(self, name_or_ordinal):
--> 363 func = self._FuncPtr((name_or_ordinal, self))
364 if not isinstance(name_or_ordinal, (int, long)):
365 func.__name__ = name_or_ordinal
AttributeError: dlsym(0x102e957d0, N_VNew_Serial): symbol not found
It’s clear something is wrong with pysundials. On closer inspection, it seems that the dynamic library isn’t loading correctly. A part of the problem is explained by this:
$ nm /usr/local/lib/libsundials*dylib
/usr/local/lib/libsundials_cvode.1.0.0.dylib:
0000000000000000 s __mh_dylib_header
U dyld_stub_binder
FFLAGS="-arch x86_64" ./configure --prefix=/usr/local --enable-examples --enable-shared
make
sudo make install
Now nm shows the items in the dylib.
In [2]: from pysundials import cvode
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/Users/alchemyst/tmp/pysundials-2.3.0-rc2/examples/cvode/serial/ in ()
/Library/Python/2.6/site-packages/pysundials/cvode.py in ()
350 if ret 352 cvode.CVodeSetFdata.argtypes = [ctypes.c_void_p, ctypes.c_void_p]
353 cvode.CVodeSetFdata.restype = ctypes.c_int
354
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ctypes/__init__.pyc in __getattr__(self, name)
356 if name.startswith('__') and name.endswith('__'):
357 raise AttributeError(name)
--> 358 func = self.__getitem__(name)
359 setattr(self, name, func)
360 return func
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ctypes/__init__.pyc in __getitem__(self, name_or_ordinal)
361
362 def __getitem__(self, name_or_ordinal):
--> 363 func = self._FuncPtr((name_or_ordinal, self))
364 if not isinstance(name_or_ordinal, (int, long)):
365 func.__name__ = name_or_ordinal
AttributeError: dlsym(0x1014d04f0, CVodeSetFdata): symbol not found
And the original thing I was trying to do:
In [1]: import jmodelica.examples.cstr as cstr
/Library/Python/2.6/site-packages/jpype/_pykeywords.py:18: DeprecationWarning: the sets module is deprecated
import sets
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
/Users/alchemyst/tmp/pysundials-2.3.0-rc2/examples/cvode/serial/ in ()
/usr/local/Python/jmodelica/examples/cstr.py in ()
9 from jmodelica.initialization.ipopt import NLPInitialization
10 from jmodelica.initialization.ipopt import InitializationOptimizer
---> 11 from jmodelica.simulation.sundials import TrajectoryLinearInterpolation
12 from jmodelica.simulation.sundials import SundialsDAESimulator
13 from jmodelica.optimization import ipopt
/usr/local/Python/jmodelica/simulation/sundials.py in ()
14
15 try:
---> 16 from pysundials import cvodes
17 from pysundials import ida
18 from pysundials import nvecserial
/Library/Python/2.6/site-packages/pysundials/cvodes.py in ()
44 NVector = nvecserial.NVector
45
---> 46 cvodes = sundials_core.loadlib("cvodes")
47
48 #Linear Multistep method constants
/Library/Python/2.6/site-packages/pysundials/sundials_core.pyc in loadlib(libname)
62 lib = ctypes.CDLL(libpaths[libname])
63 except OSError, e:
---> 64 raise OSError("%snCannot load shared library %s. Please check you config file and ensure the paths to the shared libraries are correct."%(e, libpaths[libname]))
65 return lib
66
OSError: dlopen(/usr/local/libsundials_cvodes.dylib, 6): image not found
Cannot load shared library /usr/local/libsundials_cvodes.dylib. Please check you config file and ensure the paths to the shared libraries are correct.
So the error has changed to it not finding the library. Something must be screwy with paths. Frustrating afternoon.
Leave a Reply