已安装Visual Studio C++构建工具,pip安装pycocotools仍报错
pycocotools安装失败的解决办法
- 确认Python版本为64位,执行
python -c "import platform; print(platform.architecture())"查看,32位环境大概率会编译失败 - 升级pip至最新版本:
python -m pip install --upgrade pip - 跳过源码编译,直接安装预编译wheel包:
- 找到对应Python版本和系统架构的pycocotools预编译wheel文件(可在Python非官方预编译包仓库获取)
- 执行本地安装命令:
pip install 下载的wheel文件名.whl
- 检查Visual Studio C++工具配置:
- 打开Visual Studio Installer,确保**Desktop development with C++**组件下的MSVC构建工具、对应版本Windows SDK已全部安装
- 运行VC环境配置脚本:比如64位环境执行
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"(路径根据你的VS版本调整),之后再执行pip install pycocotools
- 用conda安装替代pip:
conda install -c conda-forge pycocotools
内容的提问来源于stack exchange,提问作者Zhang Henry
相关产品推荐
相关产品推荐

