I can't install opencv-python because I don't have vs?

Question:

whenever I try to pip install opencv-python it comes with an error saying I need to install visual studio 2022 but I already have it installed. I’m completely out of ideas for how to fix this and really need opencv right now to work on my device.

I’ve tried to use opencv-contrib-python as well but that’s giving me the same error.
the error message is:

  ERROR: Command errored out with exit status 1:
   command: 'c:program filespython38python.exe' 'c:program filespython38libsite-packagespip_vendorpep517_in_process.py' build_wheel 'C:UsersNOAH~1.ROBAppDataLocalTemptmpb6spxf7z'
       cwd: C:Usersnoah.robbAppDataLocalTemppip-install-g3bef9kpopencv-contrib-python
  Complete output (332 lines):
  Not searching for unused variables given on the command line.
  CMake Error at CMakeLists.txt:2 (PROJECT):
    Generator

      Ninja

    does not support platform specification, but platform

      x64

    was specified.


  -- Configuring incomplete, errors occurred!
  See also "C:/Users/noah.robb/AppData/Local/Temp/pip-install-g3bef9kp/opencv-contrib-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
  Not searching for unused variables given on the command line.
  CMake Error at CMakeLists.txt:2 (PROJECT):
    Generator

      Visual Studio 17 2022

    could not find any instance of Visual Studio.



  -- Configuring incomplete, errors occurred!
  See also "C:/Users/noah.robb/AppData/Local/Temp/pip-install-g3bef9kp/opencv-contrib-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
  Not searching for unused variables given on the command line.
  CMake Error at CMakeLists.txt:2 (PROJECT):
    Generator

      Ninja

    does not support platform specification, but platform

      x64

    was specified.


  -- Configuring incomplete, errors occurred!
  See also "C:/Users/noah.robb/AppData/Local/Temp/pip-install-g3bef9kp/opencv-contrib-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
  Not searching for unused variables given on the command line.
  CMake Error at CMakeLists.txt:2 (PROJECT):
    Generator

      Visual Studio 16 2019

    could not find any instance of Visual Studio.



  -- Configuring incomplete, errors occurred!
  See also "C:/Users/noah.robb/AppData/Local/Temp/pip-install-g3bef9kp/opencv-contrib-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
  Not searching for unused variables given on the command line.
  CMake Error at CMakeLists.txt:2 (PROJECT):
    Generator

      Ninja

    does not support platform specification, but platform

      x64

    was specified.


  -- Configuring incomplete, errors occurred!
  See also "C:/Users/noah.robb/AppData/Local/Temp/pip-install-g3bef9kp/opencv-contrib-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
  Not searching for unused variables given on the command line.
  CMake Error at CMakeLists.txt:2 (PROJECT):
    Generator

      Visual Studio 15 2017

    could not find any instance of Visual Studio.



  -- Configuring incomplete, errors occurred!
  See also "C:/Users/noah.robb/AppData/Local/Temp/pip-install-g3bef9kp/opencv-contrib-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
  Not searching for unused variables given on the command line.
  CMake Error at CMakeLists.txt:2 (PROJECT):
    Generator

      NMake Makefiles

    does not support platform specification, but platform

      x64

    was specified.


  -- Configuring incomplete, errors occurred!
  See also "C:/Users/noah.robb/AppData/Local/Temp/pip-install-g3bef9kp/opencv-contrib-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
  Not searching for unused variables given on the command line.
  CMake Error at CMakeLists.txt:2 (PROJECT):
    Generator

      NMake Makefiles

    does not support platform specification, but platform

      x64

    was specified.


  -- Configuring incomplete, errors occurred!
  See also "C:/Users/noah.robb/AppData/Local/Temp/pip-install-g3bef9kp/opencv-contrib-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
  Not searching for unused variables given on the command line.
  CMake Error at CMakeLists.txt:2 (PROJECT):
    Generator

      NMake Makefiles

    does not support platform specification, but platform

      x64

    was specified.


  -- Configuring incomplete, errors occurred!
  See also "C:/Users/noah.robb/AppData/Local/Temp/pip-install-g3bef9kp/opencv-contrib-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".


  --------------------------------------------------------------------------------
  -- Trying "Ninja (Visual Studio 17 2022 x64 v143)" generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying "Ninja (Visual Studio 17 2022 x64 v143)" generator - failure
  --------------------------------------------------------------------------------



  --------------------------------------------------------------------------------
  -- Trying "Visual Studio 17 2022 x64 v143" generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying "Visual Studio 17 2022 x64 v143" generator - failure
  --------------------------------------------------------------------------------



  --------------------------------------------------------------------------------
  -- Trying "Ninja (Visual Studio 16 2019 x64 v142)" generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying "Ninja (Visual Studio 16 2019 x64 v142)" generator - failure
  --------------------------------------------------------------------------------



  --------------------------------------------------------------------------------
  -- Trying "Visual Studio 16 2019 x64 v142" generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying "Visual Studio 16 2019 x64 v142" generator - failure
  --------------------------------------------------------------------------------



  --------------------------------------------------------------------------------
  -- Trying "Ninja (Visual Studio 15 2017 x64 v141)" generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying "Ninja (Visual Studio 15 2017 x64 v141)" generator - failure
  --------------------------------------------------------------------------------



  --------------------------------------------------------------------------------
  -- Trying "Visual Studio 15 2017 x64 v141" generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying "Visual Studio 15 2017 x64 v141" generator - failure
  --------------------------------------------------------------------------------



  --------------------------------------------------------------------------------
  -- Trying "NMake Makefiles (Visual Studio 17 2022 x64 v143)" generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying "NMake Makefiles (Visual Studio 17 2022 x64 v143)" generator - failure
  --------------------------------------------------------------------------------



  --------------------------------------------------------------------------------
  -- Trying "NMake Makefiles (Visual Studio 16 2019 x64 v142)" generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying "NMake Makefiles (Visual Studio 16 2019 x64 v142)" generator - failure
  --------------------------------------------------------------------------------



  --------------------------------------------------------------------------------
  -- Trying "NMake Makefiles (Visual Studio 15 2017 x64 v141)" generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying "NMake Makefiles (Visual Studio 15 2017 x64 v141)" generator - failure
  --------------------------------------------------------------------------------

  ********************************************************************************
  scikit-build could not get a working generator for your system. Aborting build.

  Building windows wheels for Python 3.8 requires Microsoft Visual Studio 2022.
  Get it with "Visual Studio 2017":

    https://visualstudio.microsoft.com/vs/

  Or with "Visual Studio 2019":

    https://visualstudio.microsoft.com/vs/

  Or with "Visual Studio 2022":

    https://visualstudio.microsoft.com/vs/

  ********************************************************************************
  ----------------------------------------
  ERROR: Failed building wheel for opencv-contrib-python
  Running setup.py clean for opencv-contrib-python
Failed to build opencv-contrib-python
ERROR: Could not build wheels for opencv-contrib-python which use PEP 517 and cannot be installed directly
Asked By: Noah Robb

||

Answers:

I ran this command, and it solved the problem for me:
pip install --upgrade pip setuptools wheel
then ran this with a version specified:
pip install -U opencv-python==4.5.5.62

Answered By: DgrinderHZ

You have to install v143 c++ build tools with VS installer under "universal windows platform development" section.

Answered By: steel_wire
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.