0

After installing matlab and matlabengine (proof of the pip install in the picture) enter image description here

I get the following error:

Exception has occurred: ModuleNotFoundError
No module named 'matlab.engine'; 'matlab' is not a package
AttributeError: module 'matlab' has no attribute '__path__'

I have shared the engine on my MATLAB 2023a version and it’s active. I also added both the python3.10 version and MATLAB version to the environment variables path.

I installed matlab through the download software they provide, and there was no problem regarding installation. My operating system is Windows 11. I uninstalled all python versions and only kept 3.10 as to avoid any error of wrong version, however this uninstalls the pip too right? (just making sure). I followed these commands:

  1. cd "C:\Program Files\MATLAB\R2023a\extern\engines\python"

  2. python setup.py install

  3. pip install matlabengine

Then, in the IDE:

import matlab.engine (it will not recognise matlab.engine)
eng = matlab.engine.connect_matlab(background=True)

After using python -m pip install matlabengine (I checked the official MATLAB page and the MATLAB as well as the python version I have are compatible):

After using 'python -m pip install matlabengine'

ThickNicc
  • 21
  • 2
  • I get this error when doing import matlab.engine into my IDE – ThickNicc Mar 31 '23 at 23:27
  • 1
    How did you install it? Did you follow MATLAB’s instructions to the letter? Or is this some alternate package from PyPI? The picture you share is pointless, show us the commands you used to install this. What is your operating system? Does the `pip` command you used belong to the version of Python you are running (they each have their own `pip` command!). – Cris Luengo Apr 01 '23 at 00:18
  • @CrisLuengo thanks for your response :) I updated the question with the rest of the info, I get the error when running the code to connect matlabengine to my IDE, (I also added this step at the end of the question). – ThickNicc Apr 01 '23 at 23:51
  • One thing you could do is `python -m pip install matlabengine` instead of plain `pip …`, that way you’re certain it’s installing for that version of Python. Also, make sure in the IDE it uses the same version of Python you get when you type `python` at the command prompt. – Cris Luengo Apr 02 '23 at 02:26
  • @CrisLuengo I get the error I just added at the end of the question when doing `python -m pip install matlabengine` – ThickNicc Apr 02 '23 at 11:38

0 Answers0