Win10下安装通过源代码安装pycocotools

问题:在Win10下Conda环境中通过pip install pycocotools出现如下错误提示:

 

Building wheel for pycocotools (setup.py) ... error
ERROR: Complete output from command 'D:\Anaconda3\envs\pytorch\python.exe' -u -c 'import setuptools, tokenize;__file__
='"'"'C:\\Users\\PC\\AppData\\Local\\Temp\\pip-install-pyq04a5d\\pycocotools\\setup.py'"'"';f=getattr(tokenize, '"'"'ope
n'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'
exec'"'"'))' bdist_wheel -d 'C:\Users\PC\AppData\Local\Temp\pip-wheel-m1nzlv6o' --python-tag cp36:
ERROR: running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
creating build\lib.win-amd64-3.6\pycocotools
copying pycocotools\coco.py -> build\lib.win-amd64-3.6\pycocotools
copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.6\pycocotools
copying pycocotools\mask.py -> build\lib.win-amd64-3.6\pycocotools
copying pycocotools\__init__.py -> build\lib.win-amd64-3.6\pycocotools
running build_ext
building 'pycocotools._mask' extension
creating build\temp.win-amd64-3.6
creating build\temp.win-amd64-3.6\Release
creating build\temp.win-amd64-3.6\Release\pycocotools
creating build\temp.win-amd64-3.6\Release\common
D:\vs2015\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -ID:\Anaconda3\envs\pytorch\lib\site-packages\nu
mpy\core\include -Icommon -ID:\Anaconda3\envs\pytorch\include -ID:\Anaconda3\envs\pytorch\include -ID:\vs2015\VC\INCLUDE
-ID:\vs2015\VC\ATLMFC\INCLUDE "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files
(x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\shared" "-IC:\Program
Files (x86)\Windows Kits\8.1\include\\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\winrt" /Tcpycocotools/_mas
k.c /Fobuild\temp.win-amd64-3.6\Release\pycocotools/_mask.obj -Wno-cpp -Wno-unused-function -std=c99
cl: 命令行 error D8021 :无效的数值参数“/Wno-cpp”
error: command 'D:\\vs2015\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
----------------------------------------
ERROR: Failed building wheel for pycocotools
Running setup.py clean for pycocotools
Failed to build pycocotools
Installing collected packages: pycocotools
Running setup.py install for pycocotools ... error
ERROR: Complete output from command 'D:\Anaconda3\envs\pytorch\python.exe' -u -c 'import setuptools, tokenize;__file
__='"'"'C:\\Users\\PC\\AppData\\Local\\Temp\\pip-install-pyq04a5d\\pycocotools\\setup.py'"'"';f=getattr(tokenize, '"'"'o
pen'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'
"'exec'"'"'))' install --record 'C:\Users\PC\AppData\Local\Temp\pip-record-auc3rgky\install-record.txt' --single-version
-externally-managed --compile:
ERROR: running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
creating build\lib.win-amd64-3.6\pycocotools
copying pycocotools\coco.py -> build\lib.win-amd64-3.6\pycocotools
copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.6\pycocotools
copying pycocotools\mask.py -> build\lib.win-amd64-3.6\pycocotools
copying pycocotools\__init__.py -> build\lib.win-amd64-3.6\pycocotools
running build_ext
building 'pycocotools._mask' extension
creating build\temp.win-amd64-3.6
creating build\temp.win-amd64-3.6\Release
creating build\temp.win-amd64-3.6\Release\pycocotools
creating build\temp.win-amd64-3.6\Release\common
D:\vs2015\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -ID:\Anaconda3\envs\pytorch\lib\site-packages\
numpy\core\include -Icommon -ID:\Anaconda3\envs\pytorch\include -ID:\Anaconda3\envs\pytorch\include -ID:\vs2015\VC\INCLU
DE -ID:\vs2015\VC\ATLMFC\INCLUDE "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program File
s (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\shared" "-IC:\Progra
m Files (x86)\Windows Kits\8.1\include\\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\winrt" /Tcpycocotools/_m
ask.c /Fobuild\temp.win-amd64-3.6\Release\pycocotools/_mask.obj -Wno-cpp -Wno-unused-function -std=c99
cl: 命令行 error D8021 :无效的数值参数“/Wno-cpp”
error: command 'D:\\vs2015\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
----------------------------------------
ERROR: Command "'D:\Anaconda3\envs\pytorch\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\PC\\A
ppData\\Local\\Temp\\pip-install-pyq04a5d\\pycocotools\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__
);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install -
-record 'C:\Users\PC\AppData\Local\Temp\pip-record-auc3rgky\install-record.txt' --single-version-externally-managed --co
mpile" failed with error code 1 in C:\Users\PC\AppData\Local\Temp\pip-install-pyq04a5d\pycocotools\

 

解决方法

1. git clone https://github.com/cocodataset/cocoapi.git

2. cd cocoapi/PythonAPI

3. 删除setup.py中的红色框内的部分(如下图):

 

4. 执行:python setup.py build_ext inplace

5. 测试安装成功: python -m "import pycocotools"

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值