matlabmult​idimarrayf​orpython error

33 次查看(过去 30 天)
Hi,
I am struggling to use the MATLAB Engine API for Python.
For the installation I used the instructions here but modified it by running
python -m pip install . --prefix="path/to/conda/environment"
No error is reported so I think I installed it correctly but when I try:
import matlab.engine
eng = matlab.engine.start_matlab()
eng.sqrt(4.0)
eng.exit()
It gives the following error:
Traceback (most recent call last):
File "/data/s3375218/AutoCD/autocd/test_matlab.py", line 1, in <module>
import matlab.engine
File "/data/s3375218/smac/lib/python3.9/site-packages/matlab/__init__.py", line 218, in <module>
from matlabmultidimarrayforpython import double, single, uint8, int8, uint16, \
ModuleNotFoundError: No module named 'matlabmultidimarrayforpython'
I tried the following hacks posted here but I need to use this conda environment and I don't have enough space and I don't have root access in my remote directory to use CPython. Changing the "src/matlab/__init__.py" lead to import errors "mlarray" and "mlexceptions"
Any help will be appreciated.
Thanks!
  1 个评论
Gayatri Rathod
Gayatri Rathod 2023-5-26
编辑:Gayatri Rathod 2023-5-26
The issue is that "mlarray" and "mlexceptions" is not located in the folders located in __arch.txt. To solve this, you need to edit "src/matlab/__ init __.py" :
+ sys.path.insert(0, os.path.dirname(os.path.dirname(engine_dir)))
+ from mlexceptions import ShareError, SizeError # and remove imports from mlarray.
If the problem persists after following these steps, please provide more details about the changes you made to the __init__.py file and any relevant error messages or traceback information you are encountering after above solution.

请先登录,再进行评论。

回答(0 个)

类别

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

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by