win10安装pycocotools 出现如下错误:
$ pip install pycocotools
Collecting pycocotools
Using cached pycocotools-2.0.0.tar.gz (1.5 MB)
Building wheels for collected packages: pycocotools
Building wheel for pycocotools (setup.py): started
Building wheel for pycocotools (setup.py): finished with status 'error'
ERROR: Command errored out with exit status 1:
command: 'd:\anaconda\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\ZHENGX~1\\AppData\\Local\\Temp\\pip-install-qwghuww9\\pycocotools\\setup.py'"'"'; __file__='"'"'C:\\Users\\ZHENGX~1\\AppData\\Local\\Temp\\pip-install-qwghuww9\\pycocotools\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\ZHENGX~1\AppData\Local\Temp\pip-wheel-i2lugl_h'
cwd: C:\Users\ZHENGX~1\AppData\Local\Temp\pip-install-qwghuww9\pycocotools\
Complete output (19 lines):
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:\anaconda\lib\site-packages\numpy\core\include -Icommon -Id:\anaconda\include -Id:\anaconda\include -ID:\vs2015\VC\INCLUDE -ID:\vs2015\VC\ATLMFC\INCLUDE "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" /Tcpycocotools/_mask.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: started
Running setup.py install for pycocotools: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: 'd:\anaconda\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\ZHENGX~1\\AppData\\Local\\Temp\\pip-install-qwghuww9\\pycocotools\\setup.py'"'"'; __file__='"'"'C:\\Users\\ZHENGX~1\\AppData\\Local\\Temp\\pip-install-qwghuww9\\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\ZHENGX~1\AppData\Local\Temp\pip-record-yyw53cd7\install-record.txt' --single-version-externally-managed --compile --install-headers 'd:\anaconda\Include\pycocotools'
cwd: C:\Users\ZHENGX~1\AppData\Local\Temp\pip-install-qwghuww9\pycocotools\
Complete output (19 lines):
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:\anaconda\lib\site-packages\numpy\core\include -Icommon -Id:\anaconda\include -Id:\anaconda\include -ID:\vs2015\VC\INCLUDE -ID:\vs2015\VC\ATLMFC\INCLUDE "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" /Tcpycocotools/_mask.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 errored out with exit status 1: 'd:\anaconda\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\ZHENGX~1\\AppData\\Local\\Temp\\pip-install-qwghuww9\\pycocotools\\setup.py'"'"'; __file__='"'"'C:\\Users\\ZHENGX~1\\AppData\\Local\\Temp\\pip-install-qwghuww9\\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\ZHENGX~1\AppData\Local\Temp\pip-record-yyw53cd7\install-record.txt' --single-version-externally-managed --compile --install-headers 'd:\anaconda\Include\pycocotools' Check the logs for full command output.
好吓人,一大堆,查了以下,解决方法如下:
conda install git
pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
如果中途出现
Cloning https://github.com/philferriere/cocoapi.git to c:\users\zhengx~1\appdata\local\temp\pip-req-build-it3a4w5x
Running command git clone -q https://github.com/philferriere/cocoapi.git 'C:\Users\ZHENGX~1\AppData\Local\Temp\pip-req-build-it3a4w5x'
fatal: early EOF
fatal: The remote end hung up unexpectedly
fatal: index-pack failed
error: RPC failed; curl 56 SSL read: error:00000000:lib(0):func(0):reason(0), errno 10054
ERROR: Command errored out with exit status 128: git clone -q https://github.com/philferriere/cocoapi.git 'C:\Users\ZHENGX~1\AppData\Local\Temp\pip-req-build-it3a4w5x' Check the logs for full command output.
再重试两次就好了,最终
Successfully built pycocotools
Installing collected packages: pycocotools
Successfully installed pycocotools-2.0
参考资料:
- https://blog.csdn.net/discoverer100/article/details/101566419
- https://blog.csdn.net/XCCCCZ/article/details/82725409?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase