无法将matlab.engine安装到anaconda3环境中

g0czyy6m  于 2023-03-30  发布在  Matlab
关注(0)|答案(2)|浏览(711)

我尝试在jupyter notebook(python版本3.8.13,matlab 2020 b)中运行以下代码

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

首先,它给了我matlab的模块找不到错误。所以,我在命令提示符下执行these instructions,这就是结果(更多错误)。我不确定下一步该怎么做-还没有在网上看到类似的错误。有人建议下一步该怎么做吗?谢谢。

(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

这是我在阅读错误后尝试的两件事:

(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>

然后,我尝试了以下操作(降级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所以在最后一步之后,我只是以管理员的身份运行cmd并重试pythonsetup.py提示符,它工作了!

1tuwyuhd

1tuwyuhd1#

所以在最后一步之后,我只是以管理员的身份运行cmd并重试pythonsetup.py提示符,它工作了!

vngu2lb8

vngu2lb82#

对于那些试图安装类似于本指南的MATLAB引擎API的用户:https://fr.mathworks.com/help/matlab/matlab_external/python-setup-script-to-install-matlab-engine-api.html
我遇到了这个错误:

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

记住以Run as administrator启动cmd。
对我来说很有效。

相关问题