How to solve pycocotools installation error

496 views Asked by At

I have a problem installing a dependency for the layoutpharser library in python. This dependency is pycocotools.

So I tried following the instructions given by the GitHub page, which I link at the end, which said to install this dependency with the command:

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

But this is the error given:

Collecting git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
  Cloning https://github.com/philferriere/cocoapi.git to c:\users\lucor\appdata\local\temp\pip-req-build-uc250b20
  Running command git clone --filter=blob:none --quiet https://github.com/philferriere/cocoapi.git 'C:\Users\lucor\AppData\Local\Temp\pip-req-build-uc250b20'
  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
  ╰─> [13 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-310
      creating build\lib.win-amd64-cpython-310\pycocotools
      copying pycocotools\coco.py -> build\lib.win-amd64-cpython-310\pycocotools
      copying pycocotools\cocoeval.py -> build\lib.win-amd64-cpython-310\pycocotools
      copying pycocotools\mask.py -> build\lib.win-amd64-cpython-310\pycocotools
      copying pycocotools\__init__.py -> build\lib.win-amd64-cpython-310\pycocotools
      running build_ext
      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/
      [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\lucor\AppData\Local\Temp\pip-req-build-uc250b20\PythonAPI\setup.py", line 25, in <module>
          cythonize(ext_modules)
        File "C:\Users\lucor\ProgrammingProject\VideoLanguageProcessor\venv\lib\site-packages\Cython\Build\Dependencies.py", line 973, in cythonize      
          module_list, module_metadata = create_extension_list(
        File "C:\Users\lucor\ProgrammingProject\VideoLanguageProcessor\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\lucor\ProgrammingProject\VideoLanguageProcessor\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
ERROR: Could not build wheels for pycocotools, which is required to install pyproject.toml-based projects

Continuing in the documentation it says:

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

  • Then, run visualcppbuildtools_full.exe and select default options:

I then installed Visual C++ 2015 but I don't understand how to put it in the windows environment variables as I don't understand what directory it is in.

So I would like to ask what the corresponding directory path is or if you know of another way to install pycocotools

[https://github.com/philferriere/cocoapi] <-- THIS IS THE DOCUMENTATION LINK

Thanks a lot for the help

0

There are 0 answers