Python中安装matlab.engine出现UserWarning: The version specified (‘Rxxxx‘) is an invalid version...的解决方案

一、问题描述

       本人希望能通过Python调用Matlab引擎 (参考文章 python调用matlab程序 pycharm),在输入 python setup.py install 命令时出现问题。

(py37_env) D:\Program Files\MATLAB\R2019b\extern\engines\python>python setup.py install
C:\Users\17825\anaconda3\envs\py37_env\lib\site-packages\setuptools\dist.py:547: UserWarning: The version specified ('R2019b') 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.
  "details." % version
C:\Users\17825\anaconda3\envs\py37_env\lib\site-packages\setuptools\command\install.py:37: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  setuptools.SetuptoolsDeprecationWarning,
C:\Users\17825\anaconda3\envs\py37_env\lib\site-packages\setuptools\command\easy_install.py:147: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
  EasyInstallDeprecationWarning,
C:\Users\17825\anaconda3\envs\py37_env\lib\site-packages\pkg_resources\__init__.py:126: PkgResourcesDeprecationWarning: r2019b is an invalid version and will not be supported in a future release
  PkgResourcesDeprecationWarning,
C:\Users\17825\anaconda3\envs\py37_env\lib\site-packages\pkg_resources\__init__.py:126: PkgResourcesDeprecationWarning: r2021a is an invalid version and will not be supported in a future release
  PkgResourcesDeprecationWarning,
C:\Users\17825\anaconda3\envs\py37_env\lib\site-packages\pkg_resources\__init__.py:126: PkgResourcesDeprecationWarning: R2019b is an invalid version and will not be supported in a future release
  PkgResourcesDeprecationWarning,
C:\Users\17825\anaconda3\envs\py37_env\lib\site-packages\setuptools\command\egg_info.py:647: SetuptoolsDeprecationWarning: Custom 'build_py' does not implement 'get_data_files_without_manifest'.
Please extend command classes from setuptools instead of distutils.
  SetuptoolsDeprecationWarning
zip_safe flag not set; analyzing archive contents...
matlab.__pycache__.__init__.cpython-37: module references __file__
matlab.__pycache__.__init__.cpython-37: module references __path__
matlab.engine.__pycache__.__init__.cpython-37: module references __file__

二、解决方案

        原因是setuptools版本过高。setuptools在58.0版本以后弃用了一些方法,导致matlab.engine中的一些命令无法运行。在cmd中输入如下命令将setuptools降版本至58.0版本即可。

pip install setuptools==58.0

        在安装完成后,再次运行 python setup.py install 命令,看到如下内容时,安装成功。

running install
running build
running build_py
running install_lib
....
Writing C:\Users\17825\anaconda3\envs\py37_env\Lib\site-packages\matlabengineforpython-R2019b-py3.7.egg-info

  • 33
    点赞
  • 31
    收藏
    觉得还不错? 一键收藏
  • 12
    评论
评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值