Windows安装pycocotools的问题报错解决
作者:王大队长
最近使用pip install安装pycocotools出现错误,本文主要介绍了Windows安装pycocotools的问题报错解决,具有一定的参考价值,感兴趣的可以了解一下
pycocotools库的简介
pycocotools即python api tools of COCO。COCO是一个大型的图像数据集,用于目标检测、分割、人的关键点检测、素材分割和标题生成。这个包提供了Matlab、Python和luaapi,这些api有助于在COCO中加载、解析和可视化注释。请访问COCO - Common Objects in Context,可以了解关于COCO的更多信息,包括数据、论文和教程。COCO网站上也描述了注释的确切格式。Matlab和PythonAPI是完整的,LuaAPI只提供基本功能。
直接用下面的代码pip install 会报错
pip install pycocotools-win
报错信息:
ERROR: Command errored out with exit status 1: command: 'D:\Anaconda\anaconda\envs\pytorch1.10.1\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'D:\\temp\\pip-install-48raidr9\\pycocotools-win_9d4ff4791ad241a99d6dd3ac703b0b51\\setup.py'"'"'; __file__='"'"'D:\\temp\\pip-install -48raidr9\\pycocotools-win_9d4ff4791ad241a99d6dd3ac703b0b51\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '" '"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'D:\temp\pip-wheel-e6slyu_q' cwd: D:\temp\pip-install-48raidr9\pycocotools-win_9d4ff4791ad241a99d6dd3ac703b0b51\ Complete output (23 lines): running bdist_wheel running build running build_py creating build creating build\lib.win-amd64-3.9 creating build\lib.win-amd64-3.9\pycocotools copying pycocotools\coco.py -> build\lib.win-amd64-3.9\pycocotools copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.9\pycocotools copying pycocotools\mask.py -> build\lib.win-amd64-3.9\pycocotools copying pycocotools\__init__.py -> build\lib.win-amd64-3.9\pycocotools running build_ext cythoning pycocotools/_mask.pyx to pycocotools\_mask.c D:\Anaconda\anaconda\envs\pytorch1.10.1\lib\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: D:\temp\pip-install-48raidr9\pycocotools-win_9d4ff47 91ad241a99d6dd3ac703b0b51\pycocotools\_mask.pyx tree = Parsing.p_module(s, pxd, full_module_name) building 'pycocotools._mask' extension creating build\temp.win-amd64-3.9 creating build\temp.win-amd64-3.9\common creating build\temp.win-amd64-3.9\Release creating build\temp.win-amd64-3.9\Release\pycocotools "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.20.27508\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -ID:\Anaconda\anaconda\envs\pytorch1.10.1\lib\site-packages\numpy\core\include -I../common -ID:\Anaconda\anaconda \envs\pytorch1.10.1\include -ID:\Anaconda\anaconda\envs\pytorch1.10.1\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.20.27508\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC \14.20.27508\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Ki ts\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /Tc../common/maskApi.c /Fobuild\temp.win-amd64-3.9\Release\../common/maskApi.obj maskApi.c c1: fatal error C1083: 无法打开源文件: “../common/maskApi.c”: No such file or directory error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.20.27508\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2 ---------------------------------------- ERROR: Failed building wheel for pycocotools-win Running setup.py clean for pycocotools-win Failed to build pycocotools-win Installing collected packages: pycocotools-win Running setup.py install for pycocotools-win ... error ERROR: Command errored out with exit status 1: command: 'D:\Anaconda\anaconda\envs\pytorch1.10.1\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'D:\\temp\\pip-install-48raidr9\\pycocotools-win_9d4ff4791ad241a99d6dd3ac703b0b51\\setup.py'"'"'; __file__='"'"'D:\\temp\\pip-insta ll-48raidr9\\pycocotools-win_9d4ff4791ad241a99d6dd3ac703b0b51\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'D:\temp\pip-record-v9coqsh6\install-record.txt' --single-version-externally-managed --compile --install-headers 'D:\Anaconda\anaconda\envs\pytorch1.10.1\Include\pycocotools-win ' cwd: D:\temp\pip-install-48raidr9\pycocotools-win_9d4ff4791ad241a99d6dd3ac703b0b51\ Complete output (23 lines): running install D:\Anaconda\anaconda\envs\pytorch1.10.1\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( running build running build_py creating build creating build\lib.win-amd64-3.9 creating build\lib.win-amd64-3.9\pycocotools copying pycocotools\coco.py -> build\lib.win-amd64-3.9\pycocotools copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.9\pycocotools copying pycocotools\mask.py -> build\lib.win-amd64-3.9\pycocotools copying pycocotools\__init__.py -> build\lib.win-amd64-3.9\pycocotools running build_ext skipping 'pycocotools\_mask.c' Cython extension (up-to-date) building 'pycocotools._mask' extension creating build\temp.win-amd64-3.9 creating build\temp.win-amd64-3.9\common creating build\temp.win-amd64-3.9\Release creating build\temp.win-amd64-3.9\Release\pycocotools "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.20.27508\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -ID:\Anaconda\anaconda\envs\pytorch1.10.1\lib\site-packages\numpy\core\include -I../common -ID:\Anaconda\anacon da\envs\pytorch1.10.1\include -ID:\Anaconda\anaconda\envs\pytorch1.10.1\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.20.27508\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MS VC\14.20.27508\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /Tc../common/maskApi.c /Fobuild\temp.win-amd64-3.9\Release\../common/maskApi.obj maskApi.c c1: fatal error C1083: 无法打开源文件: “../common/maskApi.c”: No such file or directory error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.20.27508\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2 ---------------------------------------- ERROR: Command errored out with exit status 1: 'D:\Anaconda\anaconda\envs\pytorch1.10.1\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'D:\\temp\\pip-install-48raidr9\\pycocotools-win_9d4ff4791ad241a99d6dd3ac703b0b51\\setup.py'"'"'; __file__='"'"'D:\\temp\\pip-install-48raidr9\\pycocotools-win_9d4ff4791ad241a99d6dd3ac703b0b51\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'D:\temp\pip-record-v9coqsh6\install-record.txt' --single-version-externally-managed --compile --install-headers 'D:\Anaconda\anaconda\envs\pyto rch1.10.1\Include\pycocotools-win' Check the logs for full command output.
解决方法1(亲测有效):
conda install -c conda-forge pycocotools
用conda装一下就好了,并且速度也快!
解决方法2(未亲测):
conda install pycocotools -c Esri
解决方案三:
直接把这个包下载下来放到你anaconda虚拟环境所在的目录下中的site-packages文件夹内
pycococtools的安装包 pycocotools 提取码: p691
下载解压后得到两个文件,将以上两个文件夹复制至你anaconda虚拟环境所在的目录下中的site-packages文件夹内 [1]
如博主的目录为:
D:\Anaconda\ana\Lib\site-packages
参考资料:
Windows10安装pycocotools报错的一些解决方法
到此这篇关于Windows安装pycocotools的实现示例的文章就介绍到这了,更多相关Windows安装pycocotools内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!