问题描述
为实现matlab与python之间的数据交互,笔者需在python环境中安装matlab.engine引擎,按照常理来说,只要python版本与matlab版本对应上后,运行setup.py即可实现安装。
但是笔者运行后有以下报错:
SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!
********************************************************************************
Please avoid running ``setup.py`` directly.
Instead, use pypa/build, pypa/installer or other
standards-based tools.
See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
********************************************************************************
!!
self.initialize_options()
E:\Anaconda\Lib\site-packages\setuptools\_distutils\cmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!
********************************************************************************
Please avoid running ``setup.py`` and ``easy_install``.
Instead, use pypa/build, pypa/installer or other
standards-based tools.
See https://github.com/pypa/setuptools/issues/917 for details.
********************************************************************************
!!
self.initialize_options()
error: can't create or remove files in install directory
The following error occurred while trying to add or remove files in the
installation directory:
[Errno 13] Permission denied: 'E:\\Anaconda\\Lib\\site-packages\\test-easy-install-29380.write-test'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
E:\Anaconda\Lib\site-packages\
Perhaps your account does not have write access to this directory? If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account. If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.
For information on other options, you may wish to consult the
documentation at:
https://setuptools.pypa.io/en/latest/deprecated/easy_install.html
Please make the appropriate changes for your system and try again.
问题解决
注:倘若用anaconda进行不同python的管理,务必在anaconda prompt中运行setup.py文件。
检查版本对应问题
MATLAB与PYTHON之间有版本对应关系,需满足版本对应关系,对应关系可以参考:
Versions of Python Compatible with MATLAB Products by Release - MATLAB & Simulink (mathworks.cn)
查看注册表与环境变量设置
注册表
- MATLAB 在安装时会将一些信息添加到 Windows 注册表中。安装过程中,如果没有正确设置或 MATLAB 安装路径没有注册到系统中,可能会导致找不到 MATLAB。
- 打开注册表编辑器:按
Win + R,输入regedit,然后按回车。 - 导航到
HKEY_LOCAL_MACHINE\SOFTWARE\MathWorks\MATLAB,查看是否有正确的安装条目。如果没有,可能需要重新安装 MATLAB 或手动设置注册表项。
环境变量
- 确保 MATLAB 的安装路径已添加到
PATH环境变量中。 - 你可以通过以下步骤检查并设置
PATH:- 打开系统设置(右键点击 “此电脑” -> “属性” -> “高级系统设置” -> “环境变量”)。
- 在 “系统变量” 部分找到
Path变量,检查是否包含 MATLAB 安装路径,通常是C:\Program Files\MATLAB\R202Xx\bin(根据 MATLAB 版本有所不同)。 - 如果没有,手动将 MATLAB 的
bin目录路径添加到Path环境变量中。
降低setuptools版本
pip show setuptools # 查看当前版本
pip install setuptools==58
在仔细检查以上所有步骤后,再运行python setup.py,问题解决。
6847

被折叠的 条评论
为什么被折叠?



