Menu

C-integrators not working with recent versions of swig

Help
Paw
2017-07-24
2022-10-17
  • Paw

    Paw - 2017-07-24

    Dear all,

    I cannot get c-integrators to work with recent versions of swig.
    I have tried with swig3.0.10 (debian strech included) and the latest swig3.0.12.

    When I run examples/Dopri_backwards_test.py I get the error

    Error in importing compiled vector field and integrator.
    Did you compile the RHS C code?
    Traceback (most recent call last):
      File "Dopri_backwards_test.py", line 23, in <module>
        trajf = ode.compute('testf')
      File "/home/paw/.local/lib/python2.7/site-packages/PyDSTool/Generator/Dopri_ODEsystem.py", line 463, in compute
        extraSpace=self.algparams['extraspace'],
      File "/home/paw/.local/lib/python2.7/site-packages/PyDSTool/Generator/Dopri_ODEsystem.py", line 45, in __init__
        modname, *imp.find_module(modname, ["dop853_temp"]))
      File "dop853_temp/dop853_my_ode_vf.py", line 17, in <module>
        _dop853_my_ode_vf = swig_import_helper()
      File "dop853_temp/dop853_my_ode_vf.py", line 16, in swig_import_helper
        return importlib.import_module('_dop853_my_ode_vf')
      File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
        __import__(name)
    ImportError: No module named _dop853_my_ode_vf
    

    If I install swig2.0.12(latest swig2) it works as expected. I have not tried with earlier versions of swig3.
    If others have the same problem, releases of swig are found here:
    https://sourceforge.net/projects/swig/files/swig/

    best,
    Paw

     

    Last edit: Paw 2017-07-24
  • clas

    clas - 2018-11-02

    i have compilation issues too. Everything else works fine.

    What version of PyDSTool are you using?

     
  • clas

    clas - 2018-11-02

    I should have added that I am using SWIG 3 (now).

     
  • clas

    clas - 2018-11-02

    Ok. I tried to use swig 2.0. Did not work. I get the following set of error messages that I cannot (yet) decode...any help would be (much) appreciated.


    clasajacobson@clasajacobson-Oryx-Pro:~/Downloads/pydstool-master/examples$ python3 Dopri_backwards_test.py


    Present limitation of Python: Cannot rebuild library
    without exiting Python and deleting the shared library
    /home/clasajacobson/Downloads/pydstool-master/examples/_dop853_my_ode_vf.so
    by hand! If you made any changes to the system you should
    not proceed with running the integrator until you quit
    and rebuild.


    Did not compile shared library.
    Error in importing compiled vector field and integrator.
    Did you compile the RHS C code?
    Traceback (most recent call last):
    File "dop853_temp/dop853_my_ode_vf.py", line 14, in swig_import_helper
    return importlib.import_module(mname)
    File "/usr/lib/python3.6/importlib/init.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
    File "<frozen importlib._bootstrap="">", line 994, in _gcd_import
    File "<frozen importlib._bootstrap="">", line 971, in _find_and_load
    File "<frozen importlib._bootstrap="">", line 953, in _find_and_load_unlocked
    ModuleNotFoundError: No module named '_dop853_my_ode_vf'</frozen></frozen></frozen>

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "Dopri_backwards_test.py", line 23, in <module>
    trajf = ode.compute('testf')
    File "/usr/local/lib/python3.6/dist-packages/PyDSTool-0.90.2-py3.6.egg/PyDSTool/Generator/Dopri_ODEsystem.py", line 463, in compute
    extraSpace=self.algparams['extraspace'],
    File "/usr/local/lib/python3.6/dist-packages/PyDSTool-0.90.2-py3.6.egg/PyDSTool/Generator/Dopri_ODEsystem.py", line 45, in init
    modname, *imp.find_module(modname, ["dop853_temp"]))
    File "/usr/lib/python3.6/imp.py", line 235, in load_module
    return load_source(name, filename, file)
    File "/usr/lib/python3.6/imp.py", line 172, in load_source
    module = _load(spec)
    File "<frozen importlib._bootstrap="">", line 684, in _load
    File "<frozen importlib._bootstrap="">", line 665, in _load_unlocked
    File "<frozen importlib._bootstrap_external="">", line 678, in exec_module
    File "<frozen importlib._bootstrap="">", line 219, in _call_with_frames_removed
    File "dop853_temp/dop853_my_ode_vf.py", line 17, in <module>
    _dop853_my_ode_vf = swig_import_helper()
    File "dop853_temp/dop853_my_ode_vf.py", line 16, in swig_import_helper
    return importlib.import_module('_dop853_my_ode_vf')
    File "/usr/lib/python3.6/importlib/init.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
    File "<frozen importlib._bootstrap="">", line 994, in _gcd_import
    File "<frozen importlib._bootstrap="">", line 971, in _find_and_load
    File "<frozen importlib._bootstrap="">", line 953, in _find_and_load_unlocked
    ModuleNotFoundError: No module named '_dop853_my_ode_vf'
    clasajacobson@clasajacobson-Oryx-Pro:~/Downloads/pydstool-master/examples$ </frozen></frozen></frozen></module></frozen></frozen></frozen></frozen></module>

     
  • Paw

    Paw - 2022-10-17

    Five years later, I am using PyDSTool again. And I spend some time trying to figure out what I should do about this error

    Did you compile the RHS C code?
    Traceback (most recent call last):
      File "pydstool/examples/Dopri_backwards_test.py", line 23, in <module>
        trajf = ode.compute('testf')
      File "/root/projects/pydstool-ex/lib/python3.7/site-packages/PyDSTool-0.90.2-py3.7.egg/PyDSTool/Generator/Dopri_ODEsystem.py", line 465, in compute
        extraSpace=self.algparams['extraspace'],
      File "/root/projects/pydstool-ex/lib/python3.7/site-packages/PyDSTool-0.90.2-py3.7.egg/PyDSTool/Generator/Dopri_ODEsystem.py", line 46, in __init__
        package='dop853_temp',
        ...
        ModuleNotFoundError: No module named 'dop853_temp'
    

    It turns out we have to run the files from the folder they are in, ie.

    cd /path/to/pydstool/examples
    python3 Dopri_backwards_test.py
    

    I didn't read the error message properly and thought it might be a swig error. But from https://github.com/robclewley/pydstool/issues/140 we know that all swig >= 2 are supported(even swig 4).

     

Log in to post a comment.