lharri73 / PySimlink

Compile, run, and interact with Simulink models natively in Python. https://lharri73.github.io/PySimlink/
GNU General Public License v3.0
15 stars 4 forks source link

ModuleNotFoundError: No module named 'model_name_interface_c' #14

Closed djk-gmt closed 1 year ago

djk-gmt commented 1 year ago

Trying to run a model, while following each of the steps as laid out in the documentation, results in an error listed as, "ModuleNotFoundError: No module named 'fd_interface_c'" (where fd is the name of my model).

lharri73 commented 1 year ago

Hm. What OS/python version are you running?

Does it ever throw a compile/build error?

Check in the pycache folder that's created wherever you're running the script from. It should have generated a dynamic library (a .so file on mac/linux or .dll on windows) in __pycache__/pysimlink/{model_name_here}/build/out/library/ It will add this directory to python's path at runtime, and if the library is not there it will throw the import error. Did it generate the dynamic library?

djk-gmt commented 1 year ago

I'm running python 3.10 using ubuntu and I haven't run into any compile or build errors, only the error I described. Looking into the folder you suggested I found this file, model_name_interface_c.cpython-36m-x86_64-linux-gnu.so, which would seem to be the file that it claims can't be found. Any ideas why I'm still getting this error?

lharri73 commented 1 year ago

It looks like it was built for python 3.6. You can try removing the pycache directory (or really all pycache directories) and running it again.

find . -name __pycache__ -exec rm -rf {} \; should do it for a quick and dirty solution to remove all pycache directories.

djk-gmt commented 1 year ago

Ok, I think I figured it out. Looks like you were right, the python versions were screwing it up. Thanks for the help