ImportError: No module named matlab.engine

Hi,
I could not seem to import matlab.engine in python in my Ubuntu 15 as shown in the following figure:
The MATLAB Engine API for Python has been successfully installed following the instructions here http://au.mathworks.com/help/matlab/matlab_external/install-the-matlab-engine-for-python.html
Does anyone have a solution for this issue?

Réponses (5)

KIEN NGUYEN
KIEN NGUYEN le 17 Juin 2016

7 votes

This installation command, other than the original one, has worked for me: python setup.py build --build-base=$(mktemp -d) install

4 commentaires

Can you import just matlab?
>>> import matlab
YL
YL le 11 Juil 2017
Thanks!
Tino Wells
Tino Wells le 16 Juil 2019
Having the same problem - I can import matlab but once I try to import matlab.engine it says matlab is not a package.
Nicolás Ugrinovic
Nicolás Ugrinovic le 14 Fév 2020
nice, thanks!

Connectez-vous pour commenter.

Bo Li
Bo Li le 16 Juin 2016
Anaconda may not work as MATLAB Engine API for Python supports CPython only:
Another issue to consider is whether your Python version support wide-Unicode:
Following code can be used to check it supports wide Unicode or not:
>>> import sys
>>> if sys.maxunicode > 65535:
... print 'wide-unicde'
... else:
... print 'narrow-unicode'
Anshul Joshi
Anshul Joshi le 15 Mai 2018
I had the same issue with mine. I am running Ubuntu 16.04 and Python 3.6 on Pycharm, and Matlab 2018a. After installing Matlab Python API as given on http://au.mathworks.com/help/matlab/matlab_external/install-the-matlab-engine-for-python.html
it creates a folder structures like:
<installation-dir>/matlab/engine/
and
<installation-dir>/lib/ and <installation-dir>/lib.linux-x86-64-2.7/
or something like that. After I copied these directories into my Python project root they started working and I was able to import matlab.engine(). In Pycharm you can add source folders paths to your project; you can try something similar.

4 commentaires

Hongbin Liu
Hongbin Liu le 18 Juil 2018
Thank you for the answers. I would like to know what the Python project root is.
I mean the folder within which your virtual environment is created. E.g.
/home/Folder1/venv,
then
Folder1
is your python project root
Hongbin Liu
Hongbin Liu le 19 Juil 2018
Modifié(e) : Hongbin Liu le 19 Juil 2018
Nice. I have known the Python project root. Then, the folder structures like
installation-dir/matlab/engine/
should be coped into the Floder1. However, the Floder1 is not a writable file. Therefore, I do not know where the folder structures should be written into. I am just a Python beginner. It is appreciate for your help.
Hongbin Liu
Hongbin Liu le 22 Juil 2018
Modifié(e) : Hongbin Liu le 22 Juil 2018
I have addressed my problem. I found that the Python could not find the Matlab module because my computer had two Python versions. Therefore, I pointed out the Python version when the API was installed, i.e. the installing code was changed as
python3 setup.py install
Best regards and thanks again.

Connectez-vous pour commenter.

Farzadd Amirjavidd
Farzadd Amirjavidd le 9 Jan 2019

0 votes

There is a full answer to this question for windows 10 64 bit and Pycharm :
Ankit Jaiswal
Ankit Jaiswal le 8 Jan 2020

0 votes

I had same issue. I was trying it on Spyder but it didn't work. I rhen shifted to Pycharm and the error was gone. I guess there is some issue with Anaconda-Spyder.

1 commentaire

uchiha
uchiha le 20 Mar 2020
Cannot get this to work, could you explain what you did in pycharm?

Connectez-vous pour commenter.

Catégories

Commenté :

le 20 Mar 2020

Community Treasure Hunt

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

Start Hunting!

Translated by