필터 지우기
필터 지우기

matlabmult​idimarrayf​orpython error

조회 수: 33 (최근 30일)
Gerlise
Gerlise 2023년 5월 15일
편집: Gayatri Rathod 2023년 5월 26일
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