フィルターのクリア

In MATLAB I get the following python error: AttributeError: 'module' object has no attribute 'fmi'

5 ビュー (過去 30 日間)
VerunicaM
VerunicaM 2016 年 4 月 18 日
編集済み: surya venu 2024 年 7 月 16 日 6:16
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?

回答 (1 件)

surya venu
surya venu 2024 年 7 月 16 日 6:02
編集済み: surya venu 2024 年 7 月 16 日 6:16
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.

カテゴリ

Help Center および File ExchangeCall Python from MATLAB についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by