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

安装pyrevolve时出现编译错误,请求解决方法

解决pyrevolve安装时cl.exe编译失败(退出码2)的问题

问题描述

执行pip install pyrevolve时触发编译错误,cl.exe命令执行失败,退出码为2。已尝试升降Python版本、卸载Anaconda、通过conda安装、更新conda等操作,均未解决问题。

完整报错日志

Collecting pyrevolve
  Using cached pyrevolve-2.2.3.tar.gz (254 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: contexttimer in c:\users\usermain\appdata\local\programs\python\python39\lib\site-packages (from pyrevolve) (0.3.3)
Building wheels for collected packages: pyrevolve
  Building wheel for pyrevolve (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [33 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-3.9
      creating build\lib.win-amd64-3.9\pyrevolve
      copying pyrevolve\compression.py -> build\lib.win-amd64-3.9\pyrevolve
      copying pyrevolve\custom_pickle.py -> build\lib.win-amd64-3.9\pyrevolve
      copying pyrevolve\logger.py -> build\lib.win-amd64-3.9\pyrevolve
      copying pyrevolve\profiling.py -> build\lib.win-amd64-3.9\pyrevolve
      copying pyrevolve\pyrevolve.py -> build\lib.win-amd64-3.9\pyrevolve
      copying pyrevolve\storage.py -> build\lib.win-amd64-3.9\pyrevolve
      copying pyrevolve\tools.py -> build\lib.win-amd64-3.9\pyrevolve
      copying pyrevolve\_version.py -> build\lib.win-amd64-3.9\pyrevolve
      copying pyrevolve\__init__.py -> build\lib.win-amd64-3.9\pyrevolve
      creating build\lib.win-amd64-3.9\pyrevolve\schedulers
      copying pyrevolve\schedulers\base.py -> build\lib.win-amd64-3.9\pyrevolve\schedulers
      copying pyrevolve\schedulers\crevolve.py -> build\lib.win-amd64-3.9\pyrevolve\schedulers
      copying pyrevolve\schedulers\hrevolve.py -> build\lib.win-amd64-3.9\pyrevolve\schedulers
      copying pyrevolve\schedulers\__init__.py -> build\lib.win-amd64-3.9\pyrevolve\schedulers
      UPDATING build\lib.win-amd64-3.9\pyrevolve/_version.py
      set build\lib.win-amd64-3.9\pyrevolve/_version.py to '2.2.3'
      running build_ext
      building 'pyrevolve.crevolve' extension
      creating build\temp.win-amd64-3.9
      creating build\temp.win-amd64-3.9\Release
      creating build\temp.win-amd64-3.9\Release\pyrevolve
      creating build\temp.win-amd64-3.9\Release\pyrevolve\schedulers
      creating build\temp.win-amd64-3.9\Release\src
      C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -I. -Ipyrevolve -IC:\Users\Usermain\AppData\Local\Programs\Python\Python39\include -IC:\Users\Usermain\AppData\Local\Programs\Python\Python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include /EHsc /Tppyrevolve/schedulers/crevolve.cpp /Fobuild\temp.win-amd64-3.9\Release\pyrevolve/schedulers/crevolve.obj
      crevolve.cpp
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pyrevolve
  Running setup.py clean for pyrevolve
Failed to build pyrevolve
ERROR: Could not build wheels for pyrevolve, which is required to install pyproject.toml-based projects

解决方法

1. 补全Visual Studio Build Tools组件

cl.exe退出码2多因缺少编译依赖,打开Visual Studio Installer,选择“修改”你的2019 Build Tools,确保勾选以下组件:

  • MSVC v142 - VS 2019 C++ x64/x86生成工具
  • 对应系统版本的Windows SDK(如Windows 10 SDK 19041)

安装完成后重启命令行,重新执行pip install pyrevolve。

2. 手动配置VC编译环境

以管理员身份启动命令提示符,运行以下命令加载VC环境变量:

"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat"

环境配置完成后,直接在当前窗口执行安装命令。

3. 使用预编译wheel包安装

若编译始终失败,可下载对应Python 3.9版本的pyrevolve预编译wheel包,执行本地安装:

pip install pyrevolve-2.2.3-cp39-none-win_amd64.whl

4. 更新MSVC工具版本

当前使用的MSVC版本为14.29.30133,可尝试更新到最新的v142版本,确保和Python 3.9的兼容性。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.04 13:24:51