"import sunode" error

Hello everyone,

I am following the sunode installation guide from Quickstart with PyMC. For some reason, I can’t seem to run the example code posted in there past the “import sunode” line. The error message:

File "/home/admin/pymc-projects/bayesian_sunodeSAMPLE.py", line 2, in <module>
    import sunode
  File "/home/admin/anaconda3/envs/sunode-env/lib/python3.10/site-packages/sunode/__init__.py", line 3, in <module>
    from sunode.vector import empty_vector, from_numpy
  File "/home/admin/anaconda3/envs/sunode-env/lib/python3.10/site-packages/sunode/vector.py", line 8, in <module>
    from sunode import basic
  File "/home/admin/anaconda3/envs/sunode-env/lib/python3.10/site-packages/sunode/basic.py", line 15, in <module>
    import numba  # type: ignore
  File "/home/admin/anaconda3/envs/sunode-env/lib/python3.10/site-packages/numba/__init__.py", line 42, in <module>
    from numba.np.ufunc import (vectorize, guvectorize, threading_layer,
  File "/home/admin/anaconda3/envs/sunode-env/lib/python3.10/site-packages/numba/np/ufunc/__init__.py", line 3, in <module>
    from numba.np.ufunc.decorators import Vectorize, GUVectorize, vectorize, guvectorize
  File "/home/admin/anaconda3/envs/sunode-env/lib/python3.10/site-packages/numba/np/ufunc/decorators.py", line 3, in <module>
    from numba.np.ufunc import _internal
SystemError: initialization of _internal failed without raising an exception

I have tried to Google for a solution to this problem and got directed to this Error on import with numpy HEAD #8615. I followed what seems to be the solution posted in there - I tried numba v0.56.4 and v0.56.3 and both of these versions did not work with either numpy 1.23.0 or 1.24.0.

Any help would be greatly appreciated!

That does indeed look like a version incompatibility between numba and numpy. I’d have expected that this would be fixed by switching to an older numpy. Can you double check that you get a compatible version with np.version.full_version?

I think (or at least really hope) that the new numba release that is compatible with the current numpy will be released very soon. So hopefully this problem will solve itself, in the meantime you can also try to install the release candidate. (see here for installation instructions).

1 Like

Thank you for this! I double checked and found that np.version.full_version result did not match the numpy version from conda list. I fixed it by uninstalling the python that was installed outside of anaconda3.

I am encountering a new error tho:

File "/home/admin/pymc-projects/bayesian_sunodeSAMPLE.py", line 3, in <module>
    import sunode.wrappers.as_pytensor
ModuleNotFoundError: No module named 'sunode.wrappers.as_pytensor'

my current versions are:
sunode 0.2.2
sundials 5.8.0
numba 0.56.3
numpy 1.23.0
aesara 2.7.4

What version of PyMC do you have installed and how did you install it? Did you follow the official installation described here?


Following the sunode installation instructions, the packages were installed within a new environment called “sunode-env”. I had to install pymc within this environment using:

conda install "pymc>=4"

that command installed pymc v5.0.2.

With the link you shared, I followed that one and it installs pymc to an environment called pymc_env. The pymc version in there when I type in conda list is v5.1.1.

How should I resolve this issue of two separate environments?

You’ll need to combine the 2 sets of installation instructions to get both sunode and PyMC into a single environment. You can try

install -c conda-forge "pymc>=5"

in your sunode environment or you can try a corresponding approach to get sunode into the PyMC environment you created.

I tried to uninstall and reinstall the pymc within the sunode-env environment using

conda install -c conda-forge "pymc>=5"

and got the following error:
Collecting package metadata (current_repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve. Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source. Collecting package metadata (repodata.json): - Killed

Strange. Maybe @maresb or @michaelosthege might be able to suggest a solution?

It seems that there are version incompatibilities right now that conda can’t solve. I think this should solve itself if we trigger a rerender of the sunode feedstock. But I think we can wait a few more days with this until the new numba is released (it is tagged on github now, so hopefully this won’t take long now).

For me, it has been resolved after I uninstalled and installed everything back again.

Figured this out after a few mishaps. I’ll delete my comment asap!