在Windows系统中无法安装Pycocotools:致命错误C1083:无法打开包括文件:'io.h':没有那个文件或目录。错误:

9
我对机器学习很新,并且从一台搭载GeForce GTX 540M的Windows 8.1电脑开始入手。我遵循了这个教程,以了解物体检测模型的使用。我构建了自己的数据集,并尝试按照教程的要求训练了“ssd_mobilenet_v1_coco_2017_11_17”模型。但是由于我在“train.py”文件中遇到了问题,因此没有成功执行。

所以,我在谷歌上查找并发现我们必须使用“model_main.py”来训练模型。尝试使用“model_main.py”进行训练时,我遇到了以下错误:
"ImportModuleError: No module named 'pycocotools' was found"

于是我尝试从这个链接安装cocoapi。我按照给出的说明操作,但却卡在了下面显示的错误,我尝试了很多解决方案,但都没有成功。任何帮助将不胜感激。

(tensorflow1) C:\tensorflow1\models\research\object_detection>pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
Collecting git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
  Cloning https://github.com/philferriere/cocoapi.git to c:\users\home\appdata\l
ocal\temp\pip-req-build-76t4e6ys
Building wheels for collected packages: pycocotools
  Running setup.py bdist_wheel for pycocotools ... error
  Complete output from command c:\users\home\anaconda3\envs\tensorflow1\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Home\\AppData\\Local\\Temp\\pip-req-build-76t4e6ys\\PythonAPI\\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\Home\AppData\Local\Temp\pip-wheel-4_r37hm6 --python-tag cp36:
  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\common
  C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\bin\HostX86\x64\cl.exe /c/nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\home\anaconda3\envs\tensorflow1\lib\site-packages\numpy\core\include -I../common -Ic:\users\home\anaconda3\envs\tensorflow1\include -Ic:\users\home\anaconda3\envs\tensorflow1\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include" /Tcpycocotools/_mask.c /Fobuild\temp.win-amd64-3.6\Release\pycocotools/_mask.obj
  _mask.c
  c:\users\home\anaconda3\envs\tensorflow1\include\pyconfig.h(59): fatal error C1083: Cannot open include file: 'io.h': No such file or directory
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.15.26726\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2

  ----------------------------------------
  Failed building wheel for pycocotools
  Running setup.py clean for pycocotools
  Complete output from command c:\users\home\anaconda3\envs\tensorflow1\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Home\\AppData\\Local\\Temp\\pip-req-build-76t4e6ys\\PythonAPI\\setup.py';f=getattr(tokenize, 'open',open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" clean --all:
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\Home\AppData\Local\Temp\pip-req-build-76t4e6ys\PythonAPI\setup.py", line 25, in <module>
      cythonize(ext_modules)
    File "c:\users\home\anaconda3\envs\tensorflow1\lib\site-packages\Cython\Build\Dependencies.py", line 956, in cythonize
      aliases=aliases)
    File "c:\users\home\anaconda3\envs\tensorflow1\lib\site-packages\Cython\Buil
d\Dependencies.py", line 801, in create_extension_list
      for file in nonempty(sorted(extended_iglob(filepattern)), "'%s' doesn't ma
tch any files" % filepattern):
    File "c:\users\home\anaconda3\envs\tensorflow1\lib\site-packages\Cython\Buil
d\Dependencies.py", line 111, in nonempty
      raise ValueError(error_msg)
  ValueError: 'pycocotools/_mask.pyx' doesn't match any files

  ----------------------------------------
  Failed cleaning build dir for pycocotools
Failed to build pycocotools
Installing collected packages: pycocotools
  Running setup.py install for pycocotools ... error
    Complete output from command c:\users\home\anaconda3\envs\tensorflow1\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Home\\AppData\\Local\\Temp\\pip-req-build-76t4e6ys\\PythonAPI\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" build_ext "-L/C:/Program Files (x86)/Windows Kits/10/Include/10.0.17134.0/ucrt" install --record C:\Users\Home\AppData\Local\Temp\pip-record-ykypadav\install-record.txt --single-version-externally-managed --compile:
    running build_ext
    building 'pycocotools._mask' extension
    C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\bin\HostX86\x64\cl.exe /c/nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\home\anaconda3\envs\tensorflow1\lib\site-packages\numpy\core\include -I../common -Ic:\users\home\anaconda3\envs\tensorflow1\include -Ic:\users\home\anaconda3\envs\tensorflow1\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include" /Tcpycocotools/_mask.c /Fobuild\temp.win-amd64-3.6\Release\pycocotools/_mask.obj
    _mask.c
    c:\users\home\anaconda3\envs\tensorflow1\include\pyconfig.h(59): fatal error
 C1083: Cannot open include file: 'io.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.15.26726\\bin\\HostX86\\x64\\cl.exe' failed with exit
 status 2

    ----------------------------------------
Command "c:\users\home\anaconda3\envs\tensorflow1\python.exe -u -c "import setup
tools, tokenize;__file__='C:\\Users\\Home\\AppData\\Local\\Temp\\pip-req-build-76t4e6ys\\PythonAPI\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" build_ext "-L/C:/Program Files (x86)/Windows Kits/10/Include/10.0.17134.0/ucrt" install --record C:\Users\Home\AppData\Local\Temp\pip-record-ykypadav\install-record.txt --single-version-externally-managed --compile" failed with error code 1
in C:\Users\Home\AppData\Local\Temp\pip-req-build-76t4e6ys\PythonAPI

(tensorflow1) C:\tensorflow1\models\research\object_detection>
7个回答

10

简单解决方法,使用pip install pycocotools-windows


8

首先从https://go.microsoft.com/fwlink/?LinkId=691126安装Visual C++ 2015 Build Tools,并选择默认选项。然后执行以下命令:
pip install git+https://github.com/philferriere/cocoapi.git#egg=pycocotools^&subdirectory=PythonAPI


6

你可以尝试以下方法:

pip install pycocotools-windows

这对我在 Windows 工作站上的可用性有帮助 :)


12
我在Windows 10上使用Python 3.9.6和pip 21.2.4时,遇到了ERROR: Could not find a version that satisfies the requirement pycocotools-windows (from versions: none)的错误。 - Shubham Panchal

1

我遇到了同样的错误

 ValueError: 'pycocotools/_mask.pyx' doesn't match any files

我将https://github.com/waleedka/coco克隆到了本地设备。然后在运行make时,我遇到了上述错误。 我运行的确切命令是--

C:\Users\Admin\Desktop\coco-master>python3 PythonAPI/setup.py build_ext install

当我运行以上命令时,遇到了问题。后来我在同一代码库的问题页面上找到了解决方案。原来需要先进入PythonAPI目录,然后运行--
python setup.py build_ext --inplace

那对我解决了一些问题。 此外,有些人说他们仍然遇到问题,但当他们使用Python3而不是Python时,他们的问题得到了解决。


1

0
如果您遇到以下错误:Command errored out with exit status 12,请安装以下内容:
pip install git+https://github.com/philferriere/cocoapi.git#egg=pycocotools^subdirectory=PythonAPI

-1

pip install pycocotools-windows 对我有用


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接