In MATLAB I get the following python error: AttributeError: 'module' object has no attribute 'fmi'
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
When I call my custom python function py.linFMI.run() in MATLAB R2016a I get the following error:
Error using fmi_algorithm_drivers><module> (line 28)
Python Error: AttributeError: 'module' object has no attribute 'fmi'
Error in fmi>pyfmi.fmi.ModelBase._default_options (src\pyfmi\fmi.c:6394) (line 338)
Error in fmi>pyfmi.fmi.FMUModelME2.simulate_options (src\pyfmi\fmi.c:65521) (line 6515)
Error in linFMI>run (line 313)
opts=model.simulate_options()
The same function works fine in a windows or IPython console. Any ideas what is going wrong?
0 comentarios
Respuestas (1)
surya venu
el 16 de Jul. de 2024
Editada: surya venu
el 16 de Jul. de 2024
Hi,
It looks like the issue you're encountering is related to how MATLAB interfaces with Python and the specific module you're trying to use. Here are a few steps you can take to troubleshoot and potentially resolve the issue:
1) Make sure that Python version that you are using is compatible with MATAB R2016a, and "pyfmi" module is supported for the specified version of Python.
2) Verify Module Import: Before calling your function, verify that you can import the pyfmi module in MATLAB:
py.pyfmi
3) Check Python Path: Ensure that the Python path in MATLAB includes the directory where the "pyfmi" module is installed. You can add the path using:
if count(py.sys.path,'<path_to_pyfmi_module>') == 0
insert(py.sys.path,int32(0),'<path_to_pyfmi_module>');
end
4) Debugging in MATLAB: Add debugging statements in your MATLAB code to print the Python path and check if the "pyfmi" module is being correctly imported:
disp(py.sys.path);
pyfmi = py.importlib.import_module('pyfmi');
disp(py.list(pyfmi));
Hope it helps.
0 comentarios
Ver también
Categorías
Más información sobre Call Python from MATLAB en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!