Nicholaswogan/numbalsoda

Could not find module

Mark799 opened this issue · 2 comments

After running the following in Jupiter Notebook:

pip install numbalsoda

Collecting numbalsoda
  Downloading numbalsoda-0.3.4-cp39-cp39-win_amd64.whl (151 kB)
     -------------------------------------- 151.6/151.6 kB 4.4 MB/s eta 0:00:00
Requirement already satisfied: numpy in c:\users\[user]\anaconda3\lib\site-packages (from numbalsoda) (1.21.5)
Requirement already satisfied: numba in c:\users\[user]\anaconda3\lib\site-packages (from numbalsoda) (0.55.1)
Requirement already satisfied: llvmlite<0.39,>=0.38.0rc1 in c:\users\[user]\anaconda3\lib\site-packages (from numba->numbalsoda) (0.38.0)
Requirement already satisfied: setuptools in c:\users\[user]\anaconda3\lib\site-packages (from numba->numbalsoda) (63.4.1)
Installing collected packages: numbalsoda
Successfully installed numbalsoda-0.3.4
Note: you may need to restart the kernel to use updated packages.

It is not possible for me to import the package, and I get the following error message:

from numbalsoda import lsoda_sig, lsoda, dop853

FileNotFoundError: Could not find module 'C:\Users\[user]\[folder]\Gitlab\numbalsoda\numbalsoda\liblsoda.dll' (or one of its dependencies). Try using the full path with constructor syntax.

Use conda to install instead. Pip just doesn’t work well for c extensions.

I just ran into the same issue.
When using dependencies, you see that libdop853.dll requires flang.dll and other clang related dependencies.
If I comment out the loading of dop853 to only use lsoda, then it works fine.

A couple of ideas here:

  • you could use gfortran with the options -static -shared (e.g. gfortran -cpp -shared -static -o libdop853.dll libdop853.f90). Running Dependencies on the dll shows 0 external dependencies besides windows libraries. The -static option takes care of statically linking libgcc, libgfortran, libquadmath...
  • Implementing some kind of lazy loading of the dll could also be beneficial. Like this you would not face the problem with dop853 when only using lsoda

PS: as a side note, you could add the chache option @cfunc(lsoda_sig, cache=True) in your examples for better perf.
PS2: Good job btw, I could reduce my simulation time from nearly 30 sec to 0.5!