无法安装super-gradients包:onnx与pycocotools编译wheel失败
解决super-gradients安装失败:无法构建onnx和pycocotools wheel的问题
问题概述
安装super-gradients包时,pip无法完成onnx和pycocotools的wheel构建,核心错误为onnx通过cmake编译时返回非零退出状态1,关键错误日志如下:
subprocess.CalledProcessError: Command '['C:\\Program Files\\cmake-3.27.5-windows-x86_64\\bin\\cmake.exe', '-DPYTHON_INCLUDE_DIR=C:\\Program Files\\Python311\\include', '-DPYTHON_EXECUTABLE=C:\\Program Files\\Python311\\python.exe', '-DBUILD_ONNX_PYTHON=ON', '-DCMAKE_EXPORT_COMPILE_COMMANDS=ON', '-DONNX_NAMESPACE=onnx', '-DPY_EXT_SUFFIX=.cp311-win_amd64.pyd', '-DCMAKE_BUILD_TYPE=Release', '-DPY_VERSION=3.11', '-A', 'x64', '-T', 'host=x64', '-DONNX_ML=1', 'C:\\Users\\avantika hans\\AppData\\Local\\Temp\\pip-install-xy4b0tkq\\onnx_f56fe69240024f2d995c119e7073bfaa']' returned non-zero exit status 1.
后续提示无法构建pycocotools和onnx的wheel,导致super-gradients安装失败。
解决方案
1. 安装预编译wheel包(推荐,避免源码编译)
Windows平台下直接安装预编译包,跳过源码编译步骤:
- 安装onnx:
或用conda安装(兼容性更强):pip install onnx==1.14.0 --only-binary=:all:conda install -c conda-forge onnx - 安装pycocotools:
使用Windows专用替代包:
或conda安装:pip install pycocotools-windowsconda install -c conda-forge pycocotools
2. 修复源码编译依赖(如需从源码构建)
若必须源码编译,需补齐编译环境:
- 安装Visual Studio Build Tools,勾选「Desktop development with C++」组件,确保包含MSVC编译器、Windows SDK、C++标准库。
- 检查cmake版本:onnx要求cmake 3.18及以上,运行
cmake --version确认,版本不符则升级/降级到兼容版本。 - 确认使用64位Python环境:错误日志指定
-A x64,需对应安装64位Python,避免32位环境不兼容。
3. 安装super-gradients
依赖安装完成后,执行:
pip install super-gradients
内容的提问来源于stack exchange,提问作者Namita Hans
相关产品推荐
相关产品推荐

