You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

导入environment.yml时matlabengineforpython==R2020b安装失败求助

问题:导入conda环境时matlabengineforpython==R2020b安装失败

执行conda env create -f environment.yml创建环境时,pip无法找到matlabengineforpython==R2020b包,报错:

ERROR: Could not find a version that satisfies the requirement matlabengineforpython==R2020b (from versions: none)
ERROR: No matching distribution found for matlabengineforpython==R2020b

完整执行日志如下:

C:\\Software\\srv569>conda env create -f environment.yml
Collecting package metadata (repodata.json): done
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 22.9.0
  latest version: 22.11.0

Please update conda by running

    $ conda update -n base -c defaults conda


Preparing transaction: done
Verifying transaction: done
Executing transaction: done
Installing pip dependencies: \\ Ran pip subprocess with arguments:
['C:\\Software\\srv569\\Anaconda3\\envs\\research_projects\\python.exe', '-m', 'pip', 'install', '-U', '-r', 'C:\\Software\\srv569\\condaenv.0oaiyh7x.requirements.txt']
Pip subprocess output:
Collecting absl-py==1.0.0
  Using cached absl_py-1.0.0-py3-none-any.whl (126 kB)
...(省略中间包安装日志)
Collecting markupsafe==2.1.1
  Using cached MarkupSafe-2.1.1-cp38-cp38-win_amd64.whl (17 kB)

Pip subprocess error:
ERROR: Could not find a version that satisfies the requirement matlabengineforpython==R2020b (from versions: none)
ERROR: No matching distribution found for matlabengineforpython==R2020b

failed

CondaEnvException: Pip failed
解决方案

matlabengineforpython不会上传到公共PyPI源,必须依赖本地安装的对应版本MATLAB才能安装,按以下步骤处理:

  • 步骤1:确认台式机已安装MATLAB R2020b
    若未安装,需先安装MATLAB R2020b版本,确保安装时勾选了"MATLAB Engine for Python"组件(默认一般会勾选)。

  • 步骤2:手动安装MATLAB Python引擎

    1. 激活目标conda环境:
      conda activate research_projects
      
    2. 找到MATLAB安装目录下的Python引擎路径,默认路径类似:
      C:\Program Files\MATLAB\R2020b\extern\engines\python
      
    3. 进入该目录,执行安装命令:
      python setup.py install
      
  • 步骤3:跳过pip依赖先创建环境(可选)
    如果不想中断环境创建流程,可以先跳过pip依赖创建基础环境,再手动安装引擎:

    conda env create -f environment.yml --no-pip
    

    激活环境后重复步骤2的手动安装流程。

  • 步骤4:修改environment.yml(如果不需要对应版本引擎)
    若不需要MATLAB R2020b的引擎,可直接编辑environment.yml,移除matlabengineforpython==R2020b的条目,再重新执行conda env create -f environment.yml,之后按需安装兼容的MATLAB引擎版本。

内容的提问来源于stack exchange,提问作者carsof

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.09 15:35:16