Search code examples
python-3.xwindowspipinstallationanaconda

Is there a way to install cython-bbox for Windows?


I have Visual Studio installed and am trying to run a Python 3 program which depends on the cython_bbox package. I tried to install it with pip install cython-bbox on a Windows Anaconda 3 environment, but I got the following error:

  Building wheel for cython-bbox (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'C:\Users\CCL\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\CCL\\AppData\\Local\\Temp\\pip-install-du8dua7h\\cython-bbox\\setup.py'"'"'; __file__='"'"'C:\\Users\\CCL\\AppData\\Local\\Temp\\pip-install-du8dua7h\\cython-bbox\\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\CCL\AppData\Local\Temp\pip-wheel-0bojfxq5'
       cwd: C:\Users\CCL\AppData\Local\Temp\pip-install-du8dua7h\cython-bbox\
  Complete output (11 lines):
  running bdist_wheel
  running build
  running build_ext
  building 'cython_bbox' extension
  creating build
  creating build\temp.win-amd64-3.7
  creating build\temp.win-amd64-3.7\Release
  creating build\temp.win-amd64-3.7\Release\src
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\CCL\Anaconda3\lib\site-packages\numpy\core\include -IC:\Users\CCL\Anaconda3\include -IC:\Users\CCL\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include" "-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" /Tcsrc/cython_bbox.c /Fobuild\temp.win-amd64-3.7\Release\src/cython_bbox.obj -Wno-cpp
  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.24.28314\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
  ----------------------------------------
  ERROR: Failed building wheel for cython-bbox

Can this error be solved? What is /Wno-cpp? Do I need to edit some source file?


Solution

  • I just solved this problem. I downloaded the tar.gz file from PyPI, extracted it and edited the source files. To facilitate Windows support, cd into the package directory and then change line 31 in the setup.py file from extra_compile_args=['-Wno-cpp'], to extra_compile_args = {'gcc': ['/Qstd=c99']}.

    Then you can install this package from the local source using pip install -e /path/cython_bbox-0.1.3.tar/dist/cython_bbox-0.1.3/cython_bbox-0.1.3. If successful, you should see the following:

    Installing collected packages: cython-bbox
      Running setup.py develop for cython-bbox
    Successfully installed cython-bbox
    

    Here's a relevant thread for more info: https://github.com/cocodataset/cocoapi/issues/51

    Hope this helps someone!