ImportError: Matlab Engine Not Installed

7 ビュー (過去 30 日間)
alpedhuez
alpedhuez 2020 年 7 月 23 日
コメント済み: YE ZHIXIAO 2022 年 10 月 9 日
First, I have tried to use Livescript on good intentions.
Second, but Livescript does not have code folding capability.
Third, thus I want to try Matlab on Jupyter notebook on WIndows 10.
Fourth, I followed
to install the python engine.
Fifth, I installed Python and Jupyter notebook.Jupyter notebook work with Python.
Sixth, I set up Matlab on Python
Seventh, I tried to import matlab engine on Python
>>> import matlab.engine
>>> eng = matlab.engine.start_matlab()
>>>
Eighth, I open "Matlab" from Jupyter
Ninth, then I tried to run 1+1 but it does not. It gives an error message of
[MetaKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
File "C:\Users\(..)\anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 268, in dispatch_shell
yield gen.maybe_future(handler(stream, idents, msg))
File "C:\Users\(..)\anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\(..)\anaconda3\lib\site-packages\tornado\gen.py", line 209, in wrapper
yielded = next(result)
File "C:\Users\(..)\anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 541, in execute_request
user_expressions, allow_stdin,
File "C:\Users\(..)\anaconda3\lib\site-packages\metakernel\_metakernel.py", line 395, in do_execute
retval = self.do_execute_direct(code)
File "C:\Users\(..)\anaconda3\lib\site-packages\matlab_kernel\kernel.py", line 101, in do_execute_direct
retval = self._execute_sync(code)
File "C:\Users\(..)\anaconda3\lib\site-packages\matlab_kernel\kernel.py", line 270, in _execute_sync
self._matlab.eval(code, nargout=0, stdout=out, stderr=err)
File "C:\Users\(..)\anaconda3\lib\site-packages\matlab_kernel\kernel.py", line 81, in _matlab
""")
ImportError:
Matlab engine not installed:
See https://www.mathworks.com/help/matlab/matlab-engine-for-python.htm
Please advise the next step.
  4 件のコメント
Deepak Meena
Deepak Meena 2021 年 6 月 28 日
Hi , you seems to have done all the steps corretly . Only thing that I can think of is you might have two different python versions in your system. You might have integrated the matlab enigne with the wrong python version. Let me know if this is the case.
YE ZHIXIAO
YE ZHIXIAO 2022 年 10 月 9 日
@Deepak Meena Hi! Yes, I think it is this causation exactly. I encountered the same problem. So, may I ask what should I do to solve this problem "Matlab engine not installed"? I indeed installed it, but failed to start it in macos conda env or use it in jupyter. thanks for your time!

サインインしてコメントする。

回答 (1 件)

Heidi M
Heidi M 2020 年 11 月 25 日
Hello. I had the same error, and I'm using Linux. I also prefer to use Pipenv. The problem was that matlab was not in my virtual environment. So, I copied the folder into the virtualenv using the following commands:
cd /usr/local/MATLAB/R2020b/extern/engines/python/build/lib
cp -r matlab ~/.local/share/virtualenvs/MY_VIRTUAL_ENV/lib/python3.6/site-packages/matlab
You can find MY_VIRTUAL_ENV by listing the virtualenvs in the ~/.local/share directory.
Previously, I edited my bash.rc to include the following line:
export PYTHONPATH="/usr/local/MATLAB/R2020b/extern/engines/python"
However, only first step mentioned above worked.
  1 件のコメント
Heidi M
Heidi M 2020 年 11 月 25 日
Sorry- I just realized you were using Windows. Maybe copying the referenced matlab folder into site-packages works? Hopefully this helps.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeIntegration with Online Platforms についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by