3

I am trying to load the pycocotools (from here) package using PyCharm on Window 10.

At first I had the following error :

Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": 

So I installed Visual Studio 2019 and enabled the C++ packages. It look like it solved the error, but now I have another one, that is mysterious to me :

error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.21.27702\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2

And here is the full stack trace :

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: started
  Running setup.py bdist_wheel for pycocotools: finished with status 'error'
  Complete output from command [PATH\TO\VENV\]\plugin\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\[USER]\\AppData\\Local\\Temp\\pycharm-packaging\\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-u3vetp7m --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
  warning: build_py: byte-compiling is disabled, skipping.

  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
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -I[PATH\TO\VENV\]\plugin\lib\site-packages\numpy\core\include -Icommon -I[PATH\TO\VENV\]\plugin\include -IC:\Users\[USER]\AppData\Local\Programs\Python\Python36\include -IC:\Users\[USER]\AppData\Local\Programs\Python\Python36\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\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" /Tcpycocotools/_mask.c /Fobuild\temp.win-amd64-3.6\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\\2019\\Community\\VC\\Tools\\MSVC\\14.21.27702\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2

  ----------------------------------------
  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'
    Complete output from command [PATH\TO\VENV\]\plugin\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\[USER]\\AppData\\Local\\Temp\\pycharm-packaging\\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-9ez7fllv\install-record.txt --single-version-externally-managed --compile --install-headers [PATH\TO\VENV\]\plugin\include\site\python3.6\pycocotools:
    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
    warning: build_py: byte-compiling is disabled, skipping.

    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
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -I[PATH\TO\VENV\]\plugin\lib\site-packages\numpy\core\include -Icommon -I[PATH\TO\VENV\]\plugin\include -IC:\Users\[USER]\AppData\Local\Programs\Python\Python36\include -IC:\Users\[USER]\AppData\Local\Programs\Python\Python36\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\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" /Tcpycocotools/_mask.c /Fobuild\temp.win-amd64-3.6\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\\2019\\Community\\VC\\Tools\\MSVC\\14.21.27702\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2

    ----------------------------------------

  Failed building wheel for pycocotools
Command "[PATH\TO\VENV\]\plugin\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\[USER]\\AppData\\Local\\Temp\\pycharm-packaging\\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-9ez7fllv\install-record.txt --single-version-externally-managed --compile --install-headers [PATH\TO\VENV\]\plugin\include\site\python3.6\pycocotools" failed with error code 1 in C:\Users\[USER]\AppData\Local\Temp\pycharm-packaging\pycocotools\
You are using pip version 10.0.1, however version 19.1.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

What may be the problem and how can I solve it ?

Yuan JI
  • 2,487
  • 2
  • 15
  • 26
Nakeuh
  • 1,215
  • 13
  • 41
  • I get the same error trying to run: pip install pycrypto – Jortega Jun 04 '19 at 16:20
  • Update: The file include\pyport.h in Python installation directory does not have #include < stdint.h > anymore. This leaves intmax_t undefined. After following these instructions I was able to install pycrypto : https://stackoverflow.com/questions/41843266/microsoft-windows-python-3-6-pycrypto-installation-error/47749550 – Jortega Jun 04 '19 at 16:53

1 Answers1

0

Coco maintainers do not provide support in Windows, check issue #9:

We will not be providing Windows support.

But fortunately there's a fork you could compile on Windows: https://github.com/philferriere/cocoapi

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

Yuan JI
  • 2,487
  • 2
  • 15
  • 26