Clear Filters
Clear Filters

matlabmult​idimarrayf​orpython error

30 views (last 30 days)
Gerlise
Gerlise on 15 May 2023
Edited: Gayatri Rathod on 26 May 2023
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 Comment
Gayatri Rathod
Gayatri Rathod on 26 May 2023
Edited: Gayatri Rathod on 26 May 2023
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.

Sign in to comment.

Answers (0)

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!