簡體   English   中英

Could not install pycocotools in windows: fatal error C1083: Cannot open include file: 'io.h': No such file or directory 錯誤:

[英]Could not install pycocotools in windows: fatal error C1083: Cannot open include file: 'io.h': No such file or directory error:

我是機器學習的新手,開始使用配備 GeForce GTX 540M 的 windows 8.1 電腦。 我按照本教程開始使用 object 檢測模型。 我構建了自己的數據集並嘗試按照教程對其進行訓練,但使用“ssd_mobil.net_v1_coco_2017_11_17”model。但無法成功執行,因為教程中給出的“train.py”文件存在問題。

所以我用谷歌搜索,發現我們必須使用“model_main.py”來訓練 model。在嘗試使用“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>

首先從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

簡單修復,使用pip install pycocotools-windows

你可以試試:

pip install pycocotools-windows

它對我有用:) 在 Windows 站上:

我遇到了同樣的錯誤

 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

當我運行上面的命令時,我遇到了問題。 然后我在同一個存儲庫的問題頁面上找到了一個解決方案。 碰巧你必須 cd 進入 PythonAPI 然后運行——

python setup.py build_ext --inplace

那為我解決了一些問題。 此外,有些人說他們仍然遇到問題,但是當他們使用 python3 而不是 python 時,他們的問題就解決了。

嘗試以下命令(它在 Windows 10、Python 3.7.5 和 Visual 2017 上對我有用):

pip3 install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"

(來自https://github.com/cocodataset/cocoapi/issues/169#issuecomment-462528628

如果您收到此錯誤: Command errored out with exit status 12

然后安裝這個:

pip install git+https://github.com/philferriere/cocoapi.git#egg=pycocotools^subdirectory=PythonAPI

嘗試使用以下命令在 pytorch 提供的官方 docker 上安裝 pycocotools:

 pip install pycocotools

操作系統是帶有 cuda 10.0 的 Ubuntu 20.04 LTS。出現以下錯誤:

Requirement already satisfied: six in /opt/conda/lib/python3.7/site-packages (from cycler>=0.10->matplotlib>=2.1.0->pycocotools) (1.14.0)
Building wheels for collected packages: pycocotools
  Building wheel for pycocotools (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /opt/conda/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-of9_rmto/pycocotools/setup.py'"'"'; __file__='"'"'/tmp/pip-install-of9_rmto/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 /tmp/pip-wheel-4mf16plt
       cwd: /tmp/pip-install-of9_rmto/pycocotools/
  Complete output (21 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.7
  creating build/lib.linux-x86_64-3.7/pycocotools
  copying pycocotools/cocoeval.py -> build/lib.linux-x86_64-3.7/pycocotools
  copying pycocotools/__init__.py -> build/lib.linux-x86_64-3.7/pycocotools
  copying pycocotools/mask.py -> build/lib.linux-x86_64-3.7/pycocotools
  copying pycocotools/coco.py -> build/lib.linux-x86_64-3.7/pycocotools
  running build_ext
  cythoning pycocotools/_mask.pyx to pycocotools/_mask.c
  /opt/conda/lib/python3.7/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: /tmp/pip-install-of9_rmto/pycocotools/pycocotools/_mask.pyx
    tree = Parsing.p_module(s, pxd, full_module_name)
  building 'pycocotools._mask' extension
  creating build/temp.linux-x86_64-3.7
  creating build/temp.linux-x86_64-3.7/common
  creating build/temp.linux-x86_64-3.7/pycocotools
  gcc -pthread -B /opt/conda/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/opt/conda/lib/python3.7/site-packages/numpy/core/include -I./common -I/opt/conda/include/python3.7m -c ./common/maskApi.c -o build/temp.linux-x86_64-3.7/./common/maskApi.o -Wno-cpp -Wno-unused-function -std=c99
  unable to execute 'gcc': No such file or directory
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  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: Command errored out with exit status 1:
     command: /opt/conda/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-of9_rmto/pycocotools/setup.py'"'"'; __file__='"'"'/tmp/pip-install-of9_rmto/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 /tmp/pip-record-2hfbp8ni/install-record.txt --single-version-externally-managed --compile --install-headers /opt/conda/include/python3.7m/pycocotools
         cwd: /tmp/pip-install-of9_rmto/pycocotools/
    Complete output (19 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.7
    creating build/lib.linux-x86_64-3.7/pycocotools
    copying pycocotools/cocoeval.py -> build/lib.linux-x86_64-3.7/pycocotools
    copying pycocotools/__init__.py -> build/lib.linux-x86_64-3.7/pycocotools
    copying pycocotools/mask.py -> build/lib.linux-x86_64-3.7/pycocotools
    copying pycocotools/coco.py -> build/lib.linux-x86_64-3.7/pycocotools
    running build_ext
    skipping 'pycocotools/_mask.c' Cython extension (up-to-date)
    building 'pycocotools._mask' extension
    creating build/temp.linux-x86_64-3.7
    creating build/temp.linux-x86_64-3.7/common
    creating build/temp.linux-x86_64-3.7/pycocotools
    gcc -pthread -B /opt/conda/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/opt/conda/lib/python3.7/site-packages/numpy/core/include -I./common -I/opt/conda/include/python3.7m -c ./common/maskApi.c -o build/temp.linux-x86_64-3.7/./common/maskApi.o -Wno-cpp -Wno-unused-function -std=c99
    unable to execute 'gcc': No such file or directory
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /opt/conda/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-of9_rmto/pycocotools/setup.py'"'"'; __file__='"'"'/tmp/pip-install-of9_rmto/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 /tmp/pip-record-2hfbp8ni/install-record.txt --single-version-externally-managed --compile --install-headers /opt/conda/include/python3.7m/pycocotools Check the logs for full command output.

pip install pycocotools-windows 對我有用

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM