Python compatibility r2023 b

19 次查看(过去 30 天)
Stanley
Stanley 2023-11-14
回答: atharva 2023-11-16
Hi I followed the exact steps and I recently installed R2023b. I find the below error:I have Python 3.11.1
>>> import matlab.engine
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'matlab.engine'; 'matlab' is not a package

回答(1 个)

atharva
atharva 2023-11-16
Hey Stanley,
I understand that you are facing the error "ModuleNotFoundError: No module named 'matlab.engine'; 'matlab' is not a package".
One way to potentially resolve this issue is to point the "PYTHONPATH" environment variable to the directory containing the install of MATLAB Engine.This update should trigger the correct location to be searched for the necessary modules when importing.
If you are installing in a non-default location, remember to add the location to the 'PYTHONPATH' path variable. Failing to do so would mean that Python would not be able to find the MATLAB engine module.
This link discusses how to add a location to the python path:
The missing module should have been located in the following directory for 64-bit Linux machines:
\matlab\extern\engines\python\dist\matlab\engine\glnxa64
After performing re-installation, check this directory to see if it contains the MATLAB engine module. Do check that the right version of the module has been installed.
If this step does not work, one debugging step is to run Python in verbose mode when importing the module. Python can be started in verbose mode using the following command: "python -vvv".
I hope this helps!

类别

Help CenterFile Exchange 中查找有关 Call MATLAB from Python 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by