Effacer les filtres
Effacer les filtres

matlabmult​idimarrayf​orpython error

33 vues (au cours des 30 derniers jours)
Gerlise
Gerlise le 15 Mai 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 commentaire
Gayatri Rathod
Gayatri Rathod le 26 Mai 2023
Modifié(e) : Gayatri Rathod le 26 Mai 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.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Call MATLAB from Python dans Help Center et File Exchange

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by