2

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.

An old man in the sea.
  • 1,169
  • 1
  • 13
  • 30
  • The error here means that it can't reach the build tools, Visual studio is the ide, it may have not been installed with it (check the issue [here](https://github.com/benfred/implicit/issues/76)) you can download it from [here](https://visualstudio.microsoft.com/visual-cpp-build-tools/). – Mohamed abdelmagid Sep 21 '21 at 13:12
  • I also found two other questions that point the similar problems: [here](https://stackoverflow.com/questions/54915458/microsoft-visual-c-14-0-is-required-get-it-with-microsoft-visual-c-build) and [here](https://stackoverflow.com/questions/44951456/pip-error-microsoft-visual-c-14-0-is-required) – Mohamed abdelmagid Sep 21 '21 at 13:17
  • 1
    @aim97 Thanks! I've managed to download the 6GB of Visual Studio files... and it now works. =D (happy laughs despite the size...) – An old man in the sea. Sep 21 '21 at 13:22
  • Congrats, Visual studio has a vicious cycle of downloads until the problem is solved. :D. – Mohamed abdelmagid Sep 21 '21 at 13:26

1 Answers1

-1

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

xidchen
  • 69
  • 9
  • The problem with uninstalling is that the 2022 version won't replace those 2019 C runtime redistributable -- so it may break installed software -- and any future software you install may package those and re-install them with it. -- Once the runtime is there, there should never be any reason to uninstall it. – BrainSlugs83 Jun 23 '22 at 08:09