0

I'm trying to run the following code in jupyter notebook (python version 3.8.13, matlab 2020b)

import matlab.engine   
eng=matlab.engine.start_matlab()

At first it was giving me the module not found error for matlab. So, I followed these instructions in my command prompt, and this was the result (more errors). I'm not exactly sure what step to take next- haven't seen a similar error online. Anyone have suggestions on what to try next? Thanks.

(research_projects) C:\Program Files\MATLAB\R2020b\extern\engines\python>python setup.py install --prefix="c:\users\user\anaconda3\envs\research_projects"
C:\Users\User\anaconda3\envs\research_projects\lib\site-packages\setuptools\dist.py:530: UserWarning: The version specified ('R2020b') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details.
  warnings.warn(
running install
C:\Users\User\anaconda3\envs\research_projects\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
C:\Users\User\anaconda3\envs\research_projects\lib\site-packages\setuptools\command\easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
running bdist_egg
C:\Users\User\anaconda3\envs\research_projects\lib\site-packages\pkg_resources\__init__.py:122: PkgResourcesDeprecationWarning: R2020b is an invalid version and will not be supported in a future release
  warnings.warn(
running egg_info
creating dist\matlabengineforpython.egg-info
error: could not create 'dist\matlabengineforpython.egg-info': Access is denied

These are two things I've tried after reading the error:

(research_projects) C:\Program Files\MATLAB\R2020b\extern\engines\python>python3 -m pip install --prefix="c:\users\user\anaconda3\envs\research_projects"
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.

(research_projects) C:\Program Files\MATLAB\R2020b\extern\engines\python>python -m pip install --prefix="c:\users\user\anaconda3\envs\research_projects"
ERROR: You must give at least one requirement to install (see "pip help install")

(research_projects) C:\Program Files\MATLAB\R2020b\extern\engines\python>

Then, I tried the following (downgrading setup.py)

(research_projects) C:\Program Files\MATLAB\R2020b\extern\engines\python>pip install setuptools==58.2.0
Collecting setuptools==58.2.0
  Downloading setuptools-58.2.0-py3-none-any.whl (946 kB)
     |████████████████████████████████| 946 kB 2.2 MB/s
Installing collected packages: setuptools
  Attempting uninstall: setuptools
    Found existing installation: setuptools 61.2.0
    Uninstalling setuptools-61.2.0:
      Successfully uninstalled setuptools-61.2.0
Successfully installed setuptools-58.2.0

(research_projects) C:\Program Files\MATLAB\R2020b\extern\engines\python>python setup.py install --prefix="c:\users\user\anaconda3\envs\research_projects"
running install
running build
running build_py
error: You do not have write permission in build\lib\matlab\engine\

UPDATE So after that last step, I just ran cmd as an administrator & retried the python setup.py prompt & it worked! yay.

srv_77
  • 547
  • 1
  • 8
  • 20

2 Answers2

0

So after that last step, I just ran cmd as an administrator & retried the python setup.py prompt & it worked! yay.

srv_77
  • 547
  • 1
  • 8
  • 20
0

For those who are trying to install MATLAB Engine API similar to this guide: https://fr.mathworks.com/help/matlab/matlab_external/python-setup-script-to-install-matlab-engine-api.html

I met this error:

error: could not create 'dist\matlabengineforpython.egg-info': Access is denied

Remember to start your cmd with Run as administrator.

It worked in my case.

Tien PHAM
  • 7
  • 5