Error to run Python in MATLAB functions
古いコメントを表示
I am trying to run the attached 'merge_profiles.py' I has written in matlab, I don't know really the error come from where.
>> py.merge_profiles();
Undefined variable "py" or class "py.merge_profiles".
While I can run example one. I thanks anybody help me.
>> py.hello.world()
ans =
Python str with no properties.
hello world
回答 (1 件)
Dhruv
2025 年 4 月 1 日
It looks like you are trying to run a Python script, "merge_profiles.py", from MATLAB but are encountering an issue with MATLAB not recognizing the Python module. Here are some steps you can take to troubleshoot and resolve the issue:
- Verify Python Environment Setup in MATLAB: Ensure MATLAB is configured to use the correct Python environment. You can check the current Python environment by executing:
>> pyenv
You may refer to the below documentation for more details:
- Ensure Correct Module Import: After setting the path, try importing the module in MATLAB. For more details on how to call user-defined Python Module, refer to the documentation: https://www.mathworks.com/help/matlab/matlab_external/call-user-defined-custom-module.html
- MATLAB and Python Compatibility: Make sure the Python version is compatible with your MATLAB version. Check the compatibility from the following link: https://www.mathworks.com/support/requirements/python-compatibility.html
I hope this helps!
カテゴリ
ヘルプ センター および File Exchange で Call Python from MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!