Failed to build pycocotools
Asked Answered
S

2

5

I am new to machine learning and I am trying to download the requirements for a repo using

pip install -r requirements.txt

I am currently using Anaconda (3.7) version 2020.02. All the other requirements have been satisfied, this is the error I am getting:

Building wheels for collected packages: pycocotools
  Building wheel for pycocotools (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'C:\Users\Hp\anaconda3\envs\wob1\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Hp\\AppData\\Local\\Temp\\pip-req-build-mfm5emhp\\PythonAPI\\setup.py'"'"'; __file__='"'"'C:\\Users\\Hp\\AppData\\Local\\Temp\\pip-req-build-mfm5emhp\\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\Hp\AppData\Local\Temp\pip-wheel-g2bhmm6i'
       cwd: C:\Users\Hp\AppData\Local\Temp\pip-req-build-mfm5emhp\PythonAPI
  Complete output (22 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\Hp\anaconda3\envs\wob1\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\AppData\Local\Temp\pip-req-build-mfm5emhp\PythonAPI\pycocotools\_mask.pyx
    tree = Parsing.p_module(s, pxd, full_module_name)
  building 'pycocotools._mask' extension
  creating build\temp.win-amd64-3.8
  creating build\temp.win-amd64-3.8\common
  creating build\temp.win-amd64-3.8\Release
  creating build\temp.win-amd64-3.8\Release\pycocotools
  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:\Users\Hp\anaconda3\envs\wob1\lib\site-packages\numpy\core\include -I../common -IC:\Users\Hp\anaconda3\envs\wob1\include -IC:\Users\Hp\anaconda3\envs\wob1\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.26.28801\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" /Tc../common/maskApi.c /Fobuild\temp.win-amd64-3.8\Release\../common/maskApi.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\\BuildTools\\VC\\Tools\\MSVC\\14.26.28801\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
  ----------------------------------------
  ERROR: Failed building wheel for pycocotools
  Running setup.py clean for pycocotools
Failed to build pycocotools

I have tried other suggested solutions and am able to import pycocotools in the terminal and I have Microsoft Visual Studio. Any help will be appreciated, thanks.

Skater answered 2/7, 2020 at 9:59 Comment(1)
the library does not seem to offer windows support. There seem to be forks out there who do, though, see: github.com/cocodataset/cocoapi/issues/51Nissie
Z
9

If you are using Conda environment you can install like this

conda install -c conda-forge pycocotools

This solved my problem.

Zanze answered 9/1, 2022 at 16:45 Comment(1)
Bingo! This was the ticket for me.Neau
I
1

I had the same error for when I tried pip install pycocotools to my virtual environment venv. Installing pycocotools has other package dependencies - I'm not sure which exactly but it's among these here which are installed in venv. Probably just numpy and cython are necessary, but I haven't tested that.

I'm sure everything from your requirements.txt covers the dependencies already.

Make these dependencies findable by adding your venv to the PYTHONPATH in ~./bash_profile:

export PYTHONPATH="${PYTHONPATH}:path/to/venv"

If you don't have a virtual environment, then the path to the library containing the dependencies should work.

Immanuel answered 27/11, 2020 at 11:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.