Python使用setup.py安装matlab.engine时报错

部署运行你感兴趣的模型镜像

问题描述

为实现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
    1. 打开系统设置(右键点击 “此电脑” -> “属性” -> “高级系统设置” -> “环境变量”)。
    2. 在 “系统变量” 部分找到 Path 变量,检查是否包含 MATLAB 安装路径,通常是 C:\Program Files\MATLAB\R202Xx\bin(根据 MATLAB 版本有所不同)。
    3. 如果没有,手动将 MATLAB 的 bin 目录路径添加到 Path 环境变量中。

 降低setuptools版本

pip show setuptools        # 查看当前版本
pip install setuptools==58

在仔细检查以上所有步骤后,再运行python setup.py,问题解决。

您可能感兴趣的与本文相关的镜像

Python3.11

Python3.11

Conda
Python

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值