Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed building wheel for pycocotools - Windows 10 conda #169

Open
ad12 opened this issue Jun 2, 2018 · 70 comments
Open

Failed building wheel for pycocotools - Windows 10 conda #169

ad12 opened this issue Jun 2, 2018 · 70 comments

Comments

@ad12
Copy link

ad12 commented Jun 2, 2018

I am using Conda to set up a virtual environment for pycocotools. Installing pycocotools with the command pip install pycocotools. Using python 3.5 and have already installed cython

Collecting pycocotools
  Using cached https://files.pythonhosted.org/packages/96/84/9a07b1095fd8555ba3f3d519517c8743c2554a245f9476e5e39869f948d2/pycocotools-2.0.0.tar.gz
Building wheels for collected packages: pycocotools
  Running setup.py bdist_wheel for pycocotools ... error
  Complete output from command C:\Anaconda3\envs\rsl_env\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\User\\AppData\\Local\\Temp\\pip-install-rgg_uzgn\\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\User~1\AppData\Local\Temp\pip-wheel-4gdx7emo --python-tag cp35:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.5
  creating build\lib.win-amd64-3.5\pycocotools
  copying pycocotools\coco.py -> build\lib.win-amd64-3.5\pycocotools
  copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.5\pycocotools
  copying pycocotools\mask.py -> build\lib.win-amd64-3.5\pycocotools
  copying pycocotools\__init__.py -> build\lib.win-amd64-3.5\pycocotools
  running build_ext
  building 'pycocotools._mask' extension
  creating build\temp.win-amd64-3.5
  creating build\temp.win-amd64-3.5\Release
  creating build\temp.win-amd64-3.5\Release\pycocotools
  creating build\temp.win-amd64-3.5\Release\common
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Anaconda3\envs\rsl_env\lib\site-packages\numpy\core\include -Icommon -IC:\Anaconda3\envs\rsl_env\include -IC:\Anaconda3\envs\rsl_env\include /Tcpycocotools/_mask.c /Fobuild\temp.win-amd64-3.5\Release\pycocotools/_mask.obj -Wno-cpp -Wno-unused-function -std=c99
  cl : Command line error D8021 : invalid numeric argument '/Wno-cpp'
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\cl.exe' failed with exit status 2

  ----------------------------------------
  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
    Complete output from command C:\Anaconda3\envs\rsl_env\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\USER~1\\AppData\\Local\\Temp\\pip-install-rgg_uzgn\\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\USER~1\AppData\Local\Temp\pip-record-t1cjvr_9\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.5
    creating build\lib.win-amd64-3.5\pycocotools
    copying pycocotools\coco.py -> build\lib.win-amd64-3.5\pycocotools
    copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.5\pycocotools
    copying pycocotools\mask.py -> build\lib.win-amd64-3.5\pycocotools
    copying pycocotools\__init__.py -> build\lib.win-amd64-3.5\pycocotools
    running build_ext
    building 'pycocotools._mask' extension
    creating build\temp.win-amd64-3.5
    creating build\temp.win-amd64-3.5\Release
    creating build\temp.win-amd64-3.5\Release\pycocotools
    creating build\temp.win-amd64-3.5\Release\common
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Anaconda3\envs\rsl_env\lib\site-packages\numpy\core\include -Icommon -IC:\Anaconda3\envs\rsl_env\include -IC:\Anaconda3\envs\rsl_env\include /Tcpycocotools/_mask.c /Fobuild\temp.win-amd64-3.5\Release\pycocotools/_mask.obj -Wno-cpp -Wno-unused-function -std=c99
    cl : Command line error D8021 : invalid numeric argument '/Wno-cpp'
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\cl.exe' failed with exit status 2
@AdrianSalvador
Copy link

I have the same problem!

@HedgehogCode
Copy link

The maintainers won't provide support for Windows: #9 (comment)

@JaneHJ
Copy link

JaneHJ commented Aug 10, 2018

same problem! anyone have ideas how to solve it ?

@HedgehogCode
Copy link

Try this: https://github.com/philferriere/cocoapi

@woolfel
Copy link

woolfel commented Sep 17, 2018

Sure sucks that pycocotools doesn't support windows

@zbiswas3
Copy link

It does work on windows. Here is the way to fix install it.
From conda command prompt run these two commands. Just copy and paste and enter to run.
first:
conda install git
then:
pip3 install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"

@wendyltan
Copy link

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

That works! Thanks a lot bro

@m3m3-chan
Copy link

m3m3-chan commented May 9, 2019

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

This doesn't work for me sadly! I have VC 2017 could this be a problem? if not, any other ideas to solve this?
The error:

Failed to build pycocotools
Installing collected packages: pycocotools
  Running setup.py install for pycocotools ... error
    ERROR: Complete output from command 'c:\users\m\anaconda3\envs\py5cv-33\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\m\\AppData\\Local\\Temp\\pip-req-build-1bor9e4j\\PythonAPI\\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\m\AppData\Local\Temp\pip-record-9346ydwg\install-record.txt' --single-version-externally-managed --compile:
    ERROR: running install
    running build
    running build_py
    running build_ext
    building 'pycocotools._mask' extension
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\m\anaconda3\envs\py5cv-33\lib\site-packages\numpy\core\include -I../common -Ic:\users\m\anaconda3\envs\py5cv-33\include -Ic:\users\m\anaconda3\envs\py5cv-33\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" /Tcpycocotools/_mask.c /Fobuild\temp.win-amd64-3.5\Release\pycocotools/_mask.obj
    _mask.c
    c:\users\m\anaconda3\envs\py5cv-33\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(14) : Warning Msg: Using deprecated NumPy API, disable it with #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
    pycocotools/_mask.c(3186): warning C4244: '=': conversion from 'Py_ssize_t' to 'siz', possible loss of data
    pycocotools/_mask.c(3610): warning C4244: 'function': conversion from 'npy_intp' to 'siz', possible loss of data
    pycocotools/_mask.c(7040): warning C4244: '=': conversion from 'npy_intp' to 'siz', possible loss of data
    pycocotools/_mask.c(7843): warning C4244: '=': conversion from 'Py_ssize_t' to 'siz', possible loss of data
    pycocotools/_mask.c(15707): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
    pycocotools/_mask.c(15713): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\m\anaconda3\envs\py5cv-33\lib\site-packages\numpy\core\include -I../common -Ic:\users\m\anaconda3\envs\py5cv-33\include -Ic:\users\m\anaconda3\envs\py5cv-33\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" /Tc../common/maskApi.c /Fobuild\temp.win-amd64-3.5\Release\../common/maskApi.obj
    maskApi.c
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:c:\users\m\anaconda3\envs\py5cv-33\libs /LIBPATH:c:\users\m\anaconda3\envs\py5cv-33\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\um\x64" /EXPORT:PyInit__mask build\temp.win-amd64-3.5\Release\pycocotools/_mask.obj build\temp.win-amd64-3.5\Release\../common/maskApi.obj /OUT:build\lib.win-amd64-3.5\pycocotools\_mask.cp35-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.5\Release\pycocotools\_mask.cp35-win_amd64.lib
    _mask.obj : warning LNK4197: export 'PyInit__mask' specified multiple times; using first specification
       Creating library build\temp.win-amd64-3.5\Release\pycocotools\_mask.cp35-win_amd64.lib and object build\temp.win-amd64-3.5\Release\pycocotools\_mask.cp35-win_amd64.exp
    Generating code
    Finished generating code
    LINK : fatal error LNK1158: cannot run 'rc.exe'
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1158
    ----------------------------------------
ERROR: Command "'c:\users\m\anaconda3\envs\py5cv-33\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\m\\AppData\\Local\\Temp\\pip-req-build-1bor9e4j\\PythonAPI\\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\m\AppData\Local\Temp\pip-record-9346ydwg\install-record.txt' --single-version-externally-managed --compile" failed with error code 1 in C:\Users\m\AppData\Local\Temp\pip-req-build-1bor9e4j\PythonAPI

@zbiswas3
Copy link

zbiswas3 commented May 9, 2019

@m3m3-chan, You need to either reinstall your Python and visual studio or you may have to update the pip3. Looks like some of the components are missing in your root location. If it doesn't work out, use Google colab. Free from all the installation issues.

@m3m3-chan
Copy link

m3m3-chan commented May 12, 2019

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

It worked for me eventually, thanks @zbiswas3 !
I had to add the following steps to make it work:

  1. install swigwin & add "c:/path/to/swigwin4.0.0" to env variables PATH
  2. fix the issue concerning rc.exe . check the link here

@siddas27
Copy link

siddas27 commented May 14, 2019

@zbiswas3 I got the following error. Please help me out.

(tensorflow1) C:\tensorflow1\models\research>pip install "git+https://github.com/philferriere/
cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"
Collecting pycocotools from git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&su
bdirectory=PythonAPI
  Cloning https://github.com/philferriere/cocoapi.git to c:\users\siddha~1\appdata\local\temp\
pip-install-ls_3w4_2\pycocotools
  Running command git clone -q https://github.com/philferriere/cocoapi.git 'C:\Users\SIDDHA~1\
AppData\Local\Temp\pip-install-ls_3w4_2\pycocotools'
Building wheels for collected packages: pycocotools
  Building wheel for pycocotools (setup.py) ... error
  ERROR: Complete output from command 'C:\Users\siddharth\AppData\Local\Continuum\anaconda3\en
vs\tensorflow1\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\SIDDHA~
1\\AppData\\Local\\Temp\\pip-install-ls_3w4_2\\pycocotools\\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\SIDDHA~1\Ap
pData\Local\Temp\pip-wheel-pjp8glqx' --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\common
  cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -IC:\Users\siddharth\AppData\Local\Continuum\anac
onda3\envs\tensorflow1\lib\site-packages\numpy\core\include -I../common -IC:\Users\siddharth\A
ppData\Local\Continuum\anaconda3\envs\tensorflow1\include -IC:\Users\siddharth\AppData\Local\C
ontinuum\anaconda3\envs\tensorflow1\include /Tcpycocotools/_mask.c /Fobuild\temp.win-amd64-3.6
\Release\pycocotools/_mask.obj
  error: command 'cl.exe' failed: No such file or directory
  ----------------------------------------
  ERROR: Failed building wheel for pycocotools
  Running setup.py clean for pycocotools
  ERROR: Complete output from command 'C:\Users\siddharth\AppData\Local\Continuum\anaconda3\en
vs\tensorflow1\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\SIDDHA~
1\\AppData\\Local\\Temp\\pip-install-ls_3w4_2\\pycocotools\\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:
  ERROR: Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\SIDDHA~1\AppData\Local\Temp\pip-install-ls_3w4_2\pycocotools\PythonAPI\setu
p.py", line 25, in <module>
      cythonize(ext_modules)
    File "C:\Users\siddharth\AppData\Local\Continuum\anaconda3\envs\tensorflow1\lib\site-packa
ges\Cython\Build\Dependencies.py", line 967, in cythonize
      aliases=aliases)
    File "C:\Users\siddharth\AppData\Local\Continuum\anaconda3\envs\tensorflow1\lib\site-packa
ges\Cython\Build\Dependencies.py", line 812, in create_extension_list
      for file in nonempty(sorted(extended_iglob(filepattern)), "'%s' doesn't match any files"
 % filepattern):
    File "C:\Users\siddharth\AppData\Local\Continuum\anaconda3\envs\tensorflow1\lib\site-packa
ges\Cython\Build\Dependencies.py", line 111, in nonempty
      raise ValueError(error_msg)
  ValueError: 'pycocotools/_mask.pyx' doesn't match any files
  ----------------------------------------
  ERROR: Failed cleaning build dir for pycocotools
Failed to build pycocotools
Installing collected packages: pycocotools
  Running setup.py install for pycocotools ... error
    ERROR: Complete output from command 'C:\Users\siddharth\AppData\Local\Continuum\anaconda3\
envs\tensorflow1\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\SIDDH
A~1\\AppData\\Local\\Temp\\pip-install-ls_3w4_2\\pycocotools\\PythonAPI\\setup.py'"'"';f=getat
tr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"
');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\SIDDHA~
1\AppData\Local\Temp\pip-record-zcun6r8a\install-record.txt' --single-version-externally-manag
ed --compile:
    ERROR: running install
    running build
    running build_py
    running build_ext
    building 'pycocotools._mask' extension
    cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -IC:\Users\siddharth\AppData\Local\Continuum\an
aconda3\envs\tensorflow1\lib\site-packages\numpy\core\include -I../common -IC:\Users\siddharth
\AppData\Local\Continuum\anaconda3\envs\tensorflow1\include -IC:\Users\siddharth\AppData\Local
\Continuum\anaconda3\envs\tensorflow1\include /Tcpycocotools/_mask.c /Fobuild\temp.win-amd64-3
.6\Release\pycocotools/_mask.obj
    error: command 'cl.exe' failed: No such file or directory
    ----------------------------------------
ERROR: Command "'C:\Users\siddharth\AppData\Local\Continuum\anaconda3\envs\tensorflow1\python.
exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\SIDDHA~1\\AppData\\Local\\Temp\\pip-install-ls_3w4_2\\pycocotools\\PythonAPI\\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\SIDDHA~1\AppData\Local\Temp\pip-record-
zcun6r8a\install-record.txt' --single-version-externally-managed --compile" failed with error code 1 in C:\Users\SIDDHA~1\AppData\Local\Temp\pip-install-ls_3w4_2\pycocotools\PythonAPI

@zbiswas3
Copy link

@siddas27 this type of error occurs when your pyhton installation or the visual studio installation has something missing from the path directory. Also updating pip3 may solve the problem. Check out @m3m3-chans post right before yours. Trying those may also help. In my case, j reinstalled pyhton, anaconda, and visual studio. I don't know exactly which one did the magic. I will update more if I can reproduce this error on my computer.

@PrincipiaMathematic
Copy link

Thanks you very much for solving this problem it had been an unsurmountable mountain to me God bless you

@hariprasadr92
Copy link

hariprasadr92 commented Oct 19, 2019

You can skip the pycocotools by removing it from the requirements.txt ( if you have any such thing)

Or you can check the README file of COCO Git repo https://github.com/cocodataset/cocoapi
Where they have suggested that

On Windows, you must have the Visual C++ 2015 build tools on your path. If you don't, make sure to install them from here

pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
Do this and retry ur pycocotools and it should work :)

@OptiExperts
Copy link

thanks pal

@rz1027
Copy link

rz1027 commented Nov 6, 2019

pip install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"
didnt work until I changed python's version from 3.6.2 to 3.6.9
pycocotools successfully installed after

@imAhmadAsghar
Copy link

@hariprasadr92 thanks bro!

@gittering
Copy link

it took me a day to realize that the correct command for me is C:\WINDOWS\system32>pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI

@hariprasadr92
Copy link

pip install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"
didnt work until I changed python's version from 3.6.2 to 3.6.9
pycocotools successfully installed after

Yeah. I am a student and I can always update to the latest version. Maybe if you are working on it for an enterprise application, it might be difficult to upgrade the version quickly. Anyways, hope you would have figured it out :)

@chenlongtoh
Copy link

chenlongtoh commented Jan 3, 2020

I came across this error, please help me out. I am using anaconda on a virtual environment
Is it because of the io.h file, if so where do i get it?

ERROR: Command errored out with exit status 1:
command: 'c:\users\user\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\user\AppData\Local\Temp\pip-install-y1__epkk\pycocotools\PythonAPI\setup.py'"'"'; file='"'"'C:\Users\user\AppData\Local\Temp\pip-install-y1__epkk\pycocotools\PythonAPI\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\user\AppData\Local\Temp\pip-record-99mub79y\install-record.txt' --single-version-externally-managed --compile
cwd: C:\Users\user\AppData\Local\Temp\pip-install-y1__epkk\pycocotools\PythonAPI
Complete output (20 lines):
running install
running build
running build_py
creating build
creating build\lib.win32-3.7
creating build\lib.win32-3.7\pycocotools
copying pycocotools\coco.py -> build\lib.win32-3.7\pycocotools
copying pycocotools\cocoeval.py -> build\lib.win32-3.7\pycocotools
copying pycocotools\mask.py -> build\lib.win32-3.7\pycocotools
copying pycocotools_init_.py -> build\lib.win32-3.7\pycocotools
running build_ext
building 'pycocotools._mask' extension
creating build\temp.win32-3.7
creating build\temp.win32-3.7\Release
creating build\temp.win32-3.7\Release\pycocotools
creating build\temp.win32-3.7\common
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -Ic:\users\user\appdata\local\programs\python\python37-32\lib\site-packages\numpy\core\include -I../common -Ic:\users\user\appdata\local\programs\python\python37-32\include -Ic:\users\user\appdata\local\programs\python\python37-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" /Tcpycocotools/_mask.c /Fobuild\temp.win32-3.7\Release\pycocotools/_mask.obj
_mask.c
c:\users\user\appdata\local\programs\python\python37-32\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\2019\Community\VC\Tools\MSVC\14.23.28105\bin\HostX86\x86\cl.exe' failed with exit status 2
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\user\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\user\AppData\Local\Temp\pip-install-y1__epkk\pycocotools\PythonAPI\setup.py'"'"'; file='"'"'C:\Users\user\AppData\Local\Temp\pip-install-y1__epkk\pycocotools\PythonAPI\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\user\AppData\Local\Temp\pip-record-99mub79y\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.

@zbiswas3
Copy link

zbiswas3 commented Jan 3, 2020

fatal error C1083: Cannot open include file: 'io.h': No such file or directory
error: command 'C:\Program Files (x86)\Microsoft VisualStudio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\HostX86\x86\cl.exe

This sounds like you had issues with installation of Visual studio. You probably downloaded the wrong version or probably your system could not install all the required files.

Make sure you have the Visual C++ 2015 build tools on your path. So please clean up all the clutters from your pc and reinstall the visual c++ 2015 build tool.

@chenlongtoh
Copy link

fatal error C1083: Cannot open include file: 'io.h': No such file or directory
error: command 'C:\Program Files (x86)\Microsoft VisualStudio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\HostX86\x86\cl.exe

This sounds like you had issues with installation of Visual studio. You probably downloaded the wrong version or probably your system could not install all the required files.

Make sure you have the Visual C++ 2015 build tools on your path. So please clean up all the clutters from your pc and reinstall the visual c++ 2015 build tool.

Thank you very much for the solution, I installed Visual C++ 2015 Build Tools from https://go.microsoft.com/fwlink/?LinkId=691126 with default selection and ran the command and it gets installed successfully. Once again, thanks for your help.

@aymirza
Copy link

aymirza commented Feb 9, 2020

(tensorflow3) PS C:\Users\User> pip install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\envs\tensorflow3\Scripts\pip-script.py", line 6, in
from pip.internal import main
File "C:\ProgramData\Anaconda3\envs\tensorflow3\lib\site-packages\pip_internal_init
.py", line 42, in
from pip._internal import cmdoptions
File "C:\ProgramData\Anaconda3\envs\tensorflow3\lib\site-packages\pip_internal\cmdoptions.py", line 16, in
from pip._internal.index import (
ImportError: cannot import name 'FormatControl'

@khm159
Copy link

khm159 commented Feb 19, 2020

@zbiswas3 you are my hero

@TonyFPY
Copy link

TonyFPY commented Aug 10, 2020

If you are a windows user and do not want to install VS2015, you can try this:
pip install pycocotools-windows

ni ye tai tmd cong ming le ba!
You help me solve a big problem which I struggled with for 2 weeks! Thanks, bro!

@burhr2
Copy link

burhr2 commented Sep 12, 2020

@GitHongWu and @TonyFPY thanks it works for me too.

@ahmadi3d
Copy link

Finally!

installing the "Windows 10 SDK (10.0.16299.0) for Desktop C++" from the build tools did it for me! I was getting this error because of that.

Compiling pycocotools/_mask.pyx because it changed.
[1/1] Cythonizing pycocotools/_mask.pyx
C:\ProgramData\Anaconda3\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: C:\Users\HP\Downloads\Compressed\cocoapi-master_2\cocoapi-master\PythonAPI\pycocotools\_mask.pyx
  tree = Parsing.p_module(s, pxd, full_module_name)
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.7
creating build\lib.win-amd64-3.7\pycocotools
copying pycocotools\coco.py -> build\lib.win-amd64-3.7\pycocotools
copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.7\pycocotools
copying pycocotools\mask.py -> build\lib.win-amd64-3.7\pycocotools
copying pycocotools\__init__.py -> build\lib.win-amd64-3.7\pycocotools
running build_ext
building 'pycocotools._mask' extension
creating build\temp.win-amd64-3.7
creating build\temp.win-amd64-3.7\Release
creating build\temp.win-amd64-3.7\Release\pycocotools
creating build\temp.win-amd64-3.7\common
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.26.28801\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\ProgramData\Anaconda3\lib\site-packages\numpy\core\include -I../common -IC:\ProgramData\Anaconda3\include -IC:\ProgramData\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.26.28801\include" /Tcpycocotools/_mask.c /Fobuild\temp.win-amd64-3.7\Release\pycocotools/_mask.obj
_mask.c
C:\ProgramData\Anaconda3\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\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.26.28801\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2

image

Thanks. This is the only real solution that really works, instead of trying all these different packages and different version, u just have to install the Microsoft windows sdk and then a simple pip3 install pycocotools will work

@SINGIREDDYANUSHA
Copy link

ERROR: detectron2 0.3+cu101 has requirement pycocotools>=2.0.2, but you'll have pycocotools 2.0 which is incompatible.

how can i rectify this error

@luooofan
Copy link

luooofan commented Apr 7, 2021

It does work on windows. Here is the way to fix install it.
From conda command prompt run these two commands. Just copy and paste and enter to run.
first:
conda install git
then:
pip3 install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"

It works for me. Thanks!

There are two problems happened during process.

  • MSVC version. Should install msvc build tool 14.0 or later.
  • permission denied. Should run as administrator.

@anuradhab2018
Copy link

It does work on windows. Here is the way to fix install it.
From conda command prompt run these two commands. Just copy and paste and enter to run.
first:
conda install git
then:
pip3 install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"

Thanks a lot Bro..It worked !!

@drio05
Copy link

drio05 commented Jun 7, 2021

Mine got fixed!!!

I used the VS2015 x64 Native Tools Command Prompt from the Start Menu and Pycotools was installed without a single error.

Windows Command Prompt, Anaconda Command Prompt, nothing worked for me but this did. Anyone facing such issue even if VS2015 is installed should try to work it out this way

@Rock-Shell
Copy link

pip install pycocotools-windows
Worked for me after trying everything.

@NipunDewthilina
Copy link

It does work on windows. Here is the way to fix install it.
From conda command prompt run these two commands. Just copy and paste and enter to run.
first:
conda install git
then:
pip3 install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"

It did not worked for me

@navdeepgaur
Copy link

navdeepgaur commented Jul 12, 2021

None of the solutions of the solutions that kind strangers gave here worked for me.
I gave up on this error.
Then I went to the google colab sample notebook I was trying to replicate on local system, ran !python --version found out they are on python 3.7.1, downloaded python 3.7.1, installed it in a separate installation folder from my 3.9 installation, created a venv with python 3.7.1,

and

I sh*t you not:

image

@kamil3di
Copy link

I've solved the issue with this command:

pip install pycocotools-windows

@bmquynhlinh
Copy link

It does work on windows. Here is the way to fix install it.
From conda command prompt run these two commands. Just copy and paste and enter to run.
first:
conda install git
then:
pip3 install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"
I solved my problem with this solution!!!! Legit passed!

@anoldmaninthesea
Copy link

anoldmaninthesea commented Sep 21, 2021

Firstly, I'm not a CS person, I'm just someone who wants to use models as practitioner. Thanks for being understanding! ;)

I'm trying to install tf-models-official on a PC with Windows 10.

When I run pip install tf-models-official on the command prompt, I get the following error

Building wheel for pycocotools (setup.py) ... error ERROR: Command errored out with exit status 1: command: 'C:\Users\iavta\anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\iavta\AppData\Local\Temp\pip-install-0twx2hmy\pycocotools_ebdc747cefa04c81a8aab51eebf9fe53\setup.py'"'"'; file='"'"'C:\Users\iavta\AppData\Local\Temp\pip-install-0twx2hmy\pycocotools_ebdc747cefa04c81a8aab51eebf9fe53\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\iavta\AppData\Local\Temp\pip-wheel-60i3880o' cwd: C:\Users\iavta\AppData\Local\Temp\pip-install-0twx2hmy\pycocotools_ebdc747cefa04c81a8aab51eebf9fe53\ Complete output (16 lines): running bdist_wheel running build running build_py creating build creating build\lib.win-amd64-3.8 creating build\lib.win-amd64-3.8\pycocotools copying pycocotools\coco.py -> build\lib.win-amd64-3.8\pycocotools copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.8\pycocotools copying pycocotools\mask.py -> build\lib.win-amd64-3.8\pycocotools copying pycocotools_init_.py -> build\lib.win-amd64-3.8\pycocotools running build_ext cythoning pycocotools/_mask.pyx to pycocotools_mask.c C:\Users\iavta\anaconda3\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: C:\Users\iavta\AppData\Local\Temp\pip-install-0twx2hmy\pycocotools_ebdc747cefa04c81a8aab51eebf9fe53\pycocotools_mask.pyx tree = Parsing.p_module(s, pxd, full_module_name) building 'pycocotools._mask' extension error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ ---------------------------------------- ERROR: Failed building wheel for pycocotools Running setup.py clean for pycocotools Successfully built termcolor Failed to build pycocotools

I've already done pip install pycocotools-windows and I had no problems whatsoever during installation, and according to Vision Studio Installer, I have Visual Studio 2019 version 16.11.3 already installed. So, I have no idea why they ask me for Microsoft Visual C++ 14.0 or greater.

@Creator-1523
Copy link

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

That works! Thanks a lot bro

How it's not working for me please help

@xidchen
Copy link

xidchen commented Nov 30, 2021

I solved the annoying "failed building wheel for pycocotools" issue on windows 10 anaconda (python=3.9) by:

  1. Uninstall Visual Studio 2019;
  2. Uninstall all Visual C++ Redistributable (2015-2019, 2013, 2012, etc.);
  3. Install Visual Studio 2022, and tick Desktop development with C++.
  4. Activate the new virtual environment, and run "pip install tf-models-official".

image

@rmaeperito2
Copy link

It does work on windows. Here is the way to fix install it. From conda command prompt run these two commands. Just copy and paste and enter to run. first: conda install git then: pip3 install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"

This works. Thank you. :)

@ottadini
Copy link

If using conda, a search on anaconda.org reveals that pycocotools is available for win-64 on the Esri channel: https://anaconda.org/esri/pycocotools. Currently v 2.0.2.

(crack) PS C:\> conda install -c esri pycocotools
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: C:\ProgramData\Anaconda3\envs\crack

  added / updated specs:
    - pycocotools


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    cython-0.29.26             |   py38h885f38d_0         1.9 MB  conda-forge
    openssl-1.1.1k             |                1         1.9 MB  esri
    pycocotools-2.0.2          |   py38h5685391_1          93 KB  esri
    ------------------------------------------------------------
                                           Total:         3.9 MB

The following NEW packages will be INSTALLED:

  cython             conda-forge/win-64::cython-0.29.26-py38h885f38d_0
  pycocotools        esri/win-64::pycocotools-2.0.2-py38h5685391_1

The following packages will be UPDATED:

  ca-certificates    anaconda::ca-certificates-2020.10.14-0 --> conda-forge::ca-certificates-2021.10.8-h5b45459_0
  certifi                anaconda::certifi-2020.6.20-py38_0 --> conda-forge::certifi-2021.10.8-py38haa244fe_1
  openssl               anaconda::openssl-1.1.1h-he774522_0 --> esri::openssl-1.1.1k-1


Proceed ([y]/n)?

@iumyx2612
Copy link

iumyx2612 commented Mar 25, 2022

If using conda, a search on anaconda.org reveals that pycocotools is available for win-64 on the Esri channel: https://anaconda.org/esri/pycocotools. Currently v 2.0.2.

(crack) PS C:\> conda install -c esri pycocotools
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: C:\ProgramData\Anaconda3\envs\crack

  added / updated specs:
    - pycocotools


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    cython-0.29.26             |   py38h885f38d_0         1.9 MB  conda-forge
    openssl-1.1.1k             |                1         1.9 MB  esri
    pycocotools-2.0.2          |   py38h5685391_1          93 KB  esri
    ------------------------------------------------------------
                                           Total:         3.9 MB

The following NEW packages will be INSTALLED:

  cython             conda-forge/win-64::cython-0.29.26-py38h885f38d_0
  pycocotools        esri/win-64::pycocotools-2.0.2-py38h5685391_1

The following packages will be UPDATED:

  ca-certificates    anaconda::ca-certificates-2020.10.14-0 --> conda-forge::ca-certificates-2021.10.8-h5b45459_0
  certifi                anaconda::certifi-2020.6.20-py38_0 --> conda-forge::certifi-2021.10.8-py38haa244fe_1
  openssl               anaconda::openssl-1.1.1h-he774522_0 --> esri::openssl-1.1.1k-1


Proceed ([y]/n)?
Proceed ([y]/n)? y

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
ERROR conda.core.link:_execute(700): An error occurred while installing package 'defaults::qt-5.9.7-vc14h73c81de_0'.
Rolling back transaction: done

LinkError: post-link script failed for package defaults::qt-5.9.7-vc14h73c81de_0
location of failed script: E:\Anaconda\envs\openmmlab\Scripts\.qt-post-link.bat
==> script messages <==
<None>
==> script output <==
stdout:         1 file(s) copied.

stderr: 'chcp' is not recognized as an internal or external command,
operable program or batch file.
'chcp' is not recognized as an internal or external command,
operable program or batch file.
'chcp' is not recognized as an internal or external command,
operable program or batch file.

return code: 1

()

This is my output installing through Anaconda

@Nilesh-Hampiholi
Copy link

Hello I am getting the following error. Please help me. I have installed the required C++ 2015 Build Tools. Also upgraded pip.

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\320184682\appdata\local\temp\pip-req-build-q5f020t_
  Running command git clone --filter=blob:none --quiet https://github.com/philferriere/cocoapi.git 'C:\Users\320184682\AppData\Local\Temp\pip-req-build-q5f020t_'
  Resolved https://github.com/philferriere/cocoapi.git to commit 2929bd2ef6b451054755dfd7ceb09278f935f7ad
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: pycocotools
  Building wheel for pycocotools (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [22 lines of output]
      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
      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 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\320184682\PycharmProjects\notebook_venv\lib\site-packages\numpy\core\include -I../common -IC:\Users\320184682\PycharmProjects\notebook_venv\include -IC:\Users\320184682\AppData\Local\Programs\Python\Python39\include -IC:\Users\320184682\AppData\Local\Programs\Python\Python39\include -IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE -IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE -IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt /Tc../common/maskApi.c /Fobuild\temp.win-amd64-3.9\Release\../common/maskApi.obj
      maskApi.c
      C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\320184682\PycharmProjects\notebook_venv\lib\site-packages\numpy\core\include -I../common -IC:\Users\320184682\PycharmProjects\notebook_venv\include -IC:\Users\320184682\AppData\Local\Programs\Python\Python39\include -IC:\Users\320184682\AppData\Local\Programs\Python\Python39\include -IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE -IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE -IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt /Tcpycocotools/_mask.c /Fobuild\temp.win-amd64-3.9\Release\pycocotools/_mask.obj
      _mask.c
      c:\users\320184682\appdata\local\programs\python\python39\include\pyconfig.h(200): fatal error C1083: Cannot open include file: 'basetsd.h': No such file or directory
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit code 2
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pycocotools
  Running setup.py clean for pycocotools
  error: subprocess-exited-with-error

  × python setup.py clean did not run successfully.
  │ exit code: 1
  ╰─> [12 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\320184682\AppData\Local\Temp\pip-req-build-q5f020t_\PythonAPI\setup.py", line 25, in <module>
          cythonize(ext_modules)
        File "C:\Users\320184682\PycharmProjects\notebook_venv\lib\site-packages\Cython\Build\Dependencies.py", line 970, in cythonize
          module_list, module_metadata = create_extension_list(
        File "C:\Users\320184682\PycharmProjects\notebook_venv\lib\site-packages\Cython\Build\Dependencies.py", line 816, in create_extension_list
          for file in nonempty(sorted(extended_iglob(filepattern)), "'%s' doesn't match any files" % filepattern):
        File "C:\Users\320184682\PycharmProjects\notebook_venv\lib\site-packages\Cython\Build\Dependencies.py", line 114, in nonempty
          raise ValueError(error_msg)
      ValueError: 'pycocotools/_mask.pyx' doesn't match any files
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed cleaning build dir for pycocotools
Failed to build pycocotools
Installing collected packages: pycocotools
  Running setup.py install for pycocotools ... error
  error: subprocess-exited-with-error

  × Running setup.py install for pycocotools did not run successfully.
  │ exit code: 1
  ╰─> [11 lines of output]
      running install
      running build
      running build_py
      running build_ext
      building 'pycocotools._mask' extension
      C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\320184682\PycharmProjects\notebook_venv\lib\site-packages\numpy\core\include -I../common -IC:\Users\320184682\PycharmProjects\notebook_venv\include -IC:\Users\320184682\AppData\Local\Programs\Python\Python39\include -IC:\Users\320184682\AppData\Local\Programs\Python\Python39\include -IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE -IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE -IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt /Tc../common/maskApi.c /Fobuild\temp.win-amd64-3.9\Release\../common/maskApi.obj
      maskApi.c
      C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\320184682\PycharmProjects\notebook_venv\lib\site-packages\numpy\core\include -I../common -IC:\Users\320184682\PycharmProjects\notebook_venv\include -IC:\Users\320184682\AppData\Local\Programs\Python\Python39\include -IC:\Users\320184682\AppData\Local\Programs\Python\Python39\include -IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE -IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE -IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt /Tcpycocotools/_mask.c /Fobuild\temp.win-amd64-3.9\Release\pycocotools/_mask.obj
      _mask.c
      c:\users\320184682\appdata\local\programs\python\python39\include\pyconfig.h(200): fatal error C1083: Cannot open include file: 'basetsd.h': No such file or directory
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit code 2
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> pycocotools

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

@egmaminta
Copy link

Hello I am getting the following error. Please help me. I have installed the required C++ 2015 Build Tools. Also upgraded pip.


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\320184682\appdata\local\temp\pip-req-build-q5f020t_

  Running command git clone --filter=blob:none --quiet https://github.com/philferriere/cocoapi.git 'C:\Users\320184682\AppData\Local\Temp\pip-req-build-q5f020t_'

  Resolved https://github.com/philferriere/cocoapi.git to commit 2929bd2ef6b451054755dfd7ceb09278f935f7ad

  Preparing metadata (setup.py) ... done

Building wheels for collected packages: pycocotools

  Building wheel for pycocotools (setup.py) ... error

  error: subprocess-exited-with-error



  × python setup.py bdist_wheel did not run successfully.

  │ exit code: 1

  ╰─> [22 lines of output]

      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

      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 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\320184682\PycharmProjects\notebook_venv\lib\site-packages\numpy\core\include -I../common -IC:\Users\320184682\PycharmProjects\notebook_venv\include -IC:\Users\320184682\AppData\Local\Programs\Python\Python39\include -IC:\Users\320184682\AppData\Local\Programs\Python\Python39\include -IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE -IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE -IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt /Tc../common/maskApi.c /Fobuild\temp.win-amd64-3.9\Release\../common/maskApi.obj

      maskApi.c

      C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\320184682\PycharmProjects\notebook_venv\lib\site-packages\numpy\core\include -I../common -IC:\Users\320184682\PycharmProjects\notebook_venv\include -IC:\Users\320184682\AppData\Local\Programs\Python\Python39\include -IC:\Users\320184682\AppData\Local\Programs\Python\Python39\include -IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE -IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE -IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt /Tcpycocotools/_mask.c /Fobuild\temp.win-amd64-3.9\Release\pycocotools/_mask.obj

      _mask.c

      c:\users\320184682\appdata\local\programs\python\python39\include\pyconfig.h(200): fatal error C1083: Cannot open include file: 'basetsd.h': No such file or directory

      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit code 2

      [end of output]



  note: This error originates from a subprocess, and is likely not a problem with pip.

  ERROR: Failed building wheel for pycocotools

  Running setup.py clean for pycocotools

  error: subprocess-exited-with-error



  × python setup.py clean did not run successfully.

  │ exit code: 1

  ╰─> [12 lines of output]

      Traceback (most recent call last):

        File "<string>", line 2, in <module>

        File "<pip-setuptools-caller>", line 34, in <module>

        File "C:\Users\320184682\AppData\Local\Temp\pip-req-build-q5f020t_\PythonAPI\setup.py", line 25, in <module>

          cythonize(ext_modules)

        File "C:\Users\320184682\PycharmProjects\notebook_venv\lib\site-packages\Cython\Build\Dependencies.py", line 970, in cythonize

          module_list, module_metadata = create_extension_list(

        File "C:\Users\320184682\PycharmProjects\notebook_venv\lib\site-packages\Cython\Build\Dependencies.py", line 816, in create_extension_list

          for file in nonempty(sorted(extended_iglob(filepattern)), "'%s' doesn't match any files" % filepattern):

        File "C:\Users\320184682\PycharmProjects\notebook_venv\lib\site-packages\Cython\Build\Dependencies.py", line 114, in nonempty

          raise ValueError(error_msg)

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

      [end of output]



  note: This error originates from a subprocess, and is likely not a problem with pip.

  ERROR: Failed cleaning build dir for pycocotools

Failed to build pycocotools

Installing collected packages: pycocotools

  Running setup.py install for pycocotools ... error

  error: subprocess-exited-with-error



  × Running setup.py install for pycocotools did not run successfully.

  │ exit code: 1

  ╰─> [11 lines of output]

      running install

      running build

      running build_py

      running build_ext

      building 'pycocotools._mask' extension

      C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\320184682\PycharmProjects\notebook_venv\lib\site-packages\numpy\core\include -I../common -IC:\Users\320184682\PycharmProjects\notebook_venv\include -IC:\Users\320184682\AppData\Local\Programs\Python\Python39\include -IC:\Users\320184682\AppData\Local\Programs\Python\Python39\include -IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE -IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE -IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt /Tc../common/maskApi.c /Fobuild\temp.win-amd64-3.9\Release\../common/maskApi.obj

      maskApi.c

      C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\320184682\PycharmProjects\notebook_venv\lib\site-packages\numpy\core\include -I../common -IC:\Users\320184682\PycharmProjects\notebook_venv\include -IC:\Users\320184682\AppData\Local\Programs\Python\Python39\include -IC:\Users\320184682\AppData\Local\Programs\Python\Python39\include -IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE -IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE -IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt /Tcpycocotools/_mask.c /Fobuild\temp.win-amd64-3.9\Release\pycocotools/_mask.obj

      _mask.c

      c:\users\320184682\appdata\local\programs\python\python39\include\pyconfig.h(200): fatal error C1083: Cannot open include file: 'basetsd.h': No such file or directory

      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit code 2

      [end of output]



  note: This error originates from a subprocess, and is likely not a problem with pip.

error: legacy-install-failure



× Encountered error while trying to install package.

╰─> pycocotools



note: This is an issue with the package mentioned above, not pip.

hint: See above for output from the failure.

We also both have the same problem... my basetsd.h file is not found. Did u solve this?

@Robotatron
Copy link

If using conda, a search on anaconda.org reveals that pycocotools is available for win-64 on the Esri channel: https://anaconda.org/esri/pycocotools. Currently v 2.0.2.

(crack) PS C:\> conda install -c esri pycocotools
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: C:\ProgramData\Anaconda3\envs\crack

  added / updated specs:
    - pycocotools


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    cython-0.29.26             |   py38h885f38d_0         1.9 MB  conda-forge
    openssl-1.1.1k             |                1         1.9 MB  esri
    pycocotools-2.0.2          |   py38h5685391_1          93 KB  esri
    ------------------------------------------------------------
                                           Total:         3.9 MB

The following NEW packages will be INSTALLED:

  cython             conda-forge/win-64::cython-0.29.26-py38h885f38d_0
  pycocotools        esri/win-64::pycocotools-2.0.2-py38h5685391_1

The following packages will be UPDATED:

  ca-certificates    anaconda::ca-certificates-2020.10.14-0 --> conda-forge::ca-certificates-2021.10.8-h5b45459_0
  certifi                anaconda::certifi-2020.6.20-py38_0 --> conda-forge::certifi-2021.10.8-py38haa244fe_1
  openssl               anaconda::openssl-1.1.1h-he774522_0 --> esri::openssl-1.1.1k-1


Proceed ([y]/n)?

Thank you! Works in 2022 on Windows 10

@saeedfx
Copy link

saeedfx commented Sep 14, 2022

I install visual studio then install visual studio build tools and my problem solved

@KaiquanMah
Copy link

KaiquanMah commented Jan 20, 2023

Using @Robotatron's answer, I tried
conda install -c esri pycocotools

Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: /
Found conflicts! Looking for incompatible packages.
This can take several minutes. Press CTRL-C to abort.
failed
UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:
Specifications:
pycocotools -> python[version='>=3.6,<3.7.0a0|>=3.8,<3.9.0a0|>=3.7,<3.8.0a0|>=3.9,<3.10.0a0']
Your python: python=3.10
If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.

After downgrading my python version from v3.10 to v3.9, the following code ran successfully in my 'anaconda prompt'
conda install -c esri pycocotools

@MjdMahasneh
Copy link

Finally!
installing the "Windows 10 SDK (10.0.16299.0) for Desktop C++" from the build tools did it for me! I was getting this error because of that.

Compiling pycocotools/_mask.pyx because it changed.
[1/1] Cythonizing pycocotools/_mask.pyx
C:\ProgramData\Anaconda3\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: C:\Users\HP\Downloads\Compressed\cocoapi-master_2\cocoapi-master\PythonAPI\pycocotools\_mask.pyx
  tree = Parsing.p_module(s, pxd, full_module_name)
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.7
creating build\lib.win-amd64-3.7\pycocotools
copying pycocotools\coco.py -> build\lib.win-amd64-3.7\pycocotools
copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.7\pycocotools
copying pycocotools\mask.py -> build\lib.win-amd64-3.7\pycocotools
copying pycocotools\__init__.py -> build\lib.win-amd64-3.7\pycocotools
running build_ext
building 'pycocotools._mask' extension
creating build\temp.win-amd64-3.7
creating build\temp.win-amd64-3.7\Release
creating build\temp.win-amd64-3.7\Release\pycocotools
creating build\temp.win-amd64-3.7\common
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.26.28801\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\ProgramData\Anaconda3\lib\site-packages\numpy\core\include -I../common -IC:\ProgramData\Anaconda3\include -IC:\ProgramData\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.26.28801\include" /Tcpycocotools/_mask.c /Fobuild\temp.win-amd64-3.7\Release\pycocotools/_mask.obj
_mask.c
C:\ProgramData\Anaconda3\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\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.26.28801\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2

image

Thanks. This is the only real solution that really works, instead of trying all these different packages and different version, u just have to install the Microsoft windows sdk and then a simple pip3 install pycocotools will work

Thank you, it worked for me too.

Context:

I was trying to install Detectron2 (which needs pycocotools in turn) when I bumped into this error.
I use Windows 10, in a conda environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests