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

Python 3.13.1环境下pip安装CatBoost遭遇KeyError: 'VERSION'错误的解决请求

Python 3.13.1环境下pip安装CatBoost遭遇KeyError: 'VERSION'错误的解决请求

我最近在做一个机器学习项目,需要用pip安装CatBoost和XGBoost。XGBoost已经顺利装好了,但CatBoost一直抛出同一个错误,折腾了好半天都没解决,想请各位大佬帮忙看看怎么修复这个问题。

以下是我执行安装命令时的完整错误输出:

(venv) D:\ML bootcamp\mlproject>pip install catboost        
Collecting catboost
  Using cached catboost-1.2.7.tar.gz (71.5 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [24 lines of output]
      Traceback (most recent call last):
        File "D:\ML bootcamp\mlproject\venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 389, in <module>
          main()
        File "D:\ML bootcamp\mlproject\venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 373, in main
          json_out["return_val"] = hook(**hook_input["kwargs"])
        File "D:\ML bootcamp\mlproject\venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 143, in get_requires_for_build_wheel
          return hook(config_settings)
        File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-xzdiplgy\overlay\Lib\site-packages\setuptools\build_meta.py", line 334, in get_requires_for_build_wheel       
          return self._get_build_requires(config_settings, requirements=[])
        File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-xzdiplgy\overlay\Lib\site-packages\setuptools\build_meta.py", line 304, in _get_build_requires
          self.run_setup()
        File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-xzdiplgy\overlay\Lib\site-packages\setuptools\build_meta.py", line 522, in run_setup
          super().run_setup(setup_script=setup_script)      
        File "<string>", line 733, in <module>
        File "<string>", line 205, in get_catboost_version
      KeyError: 'VERSION'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

可能的修复方案

  • 优先安装预编译二进制包:这个错误看起来是源码编译时读取版本信息失败,直接强制安装预编译的二进制包可以绕开编译步骤,试试这条命令:
    pip install catboost --only-binary :all:
    
  • 升级打包工具后重试:旧版本的pip、setuptools可能和Python 3.13不兼容,先更新这些工具再尝试安装:
    pip install --upgrade pip setuptools wheel
    pip install catboost
    
  • 降级Python版本:Python 3.13是较新的正式版,部分第三方库可能还没完成适配。如果项目对Python版本没有强制要求,可以降级到3.12或3.11版本,再尝试安装CatBoost,兼容性会更好。
  • 安装CatBoost开发版本:如果正式版还没修复适配问题,试试从GitHub仓库安装最新的开发分支,可能已经解决了Python 3.13的兼容问题:
    pip install git+https://github.com/catboost/catboost.git
    

备注:内容来源于stack exchange,提问作者Mohammed Saim Quadri

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.14 10:13:06