2

Ran: pip install opencv-python

from windows cmd with admin. First time setting up python and I don't think it's using the right environment variables

getting this error:

Collecting opencv-python
  Using cached opencv-python-4.4.0.44.tar.gz (88.9 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Processing c:\users\shub\appdata\local\pip\cache\wheels\a3\17\dd\f2dba23a35bb6008732772ccfb13d3d0e537fbc6919ce6862b\numpy-1.19.2-cp39-cp39-win_amd64.whl
Building wheels for collected packages: opencv-python
  Building wheel for opencv-python (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\users\shub\appdata\local\programs\python\python39\python.exe' 'c:\users\shub\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\pep517\_in_process.py' build_wheel 'C:\Users\Shub\AppData\Local\Temp\tmpmlx70j_s'
       cwd: C:\Users\Shub\AppData\Local\Temp\pip-install-tdd7o170\opencv-python
  Complete output (153 lines):
  Not searching for unused variables given on the command line.
  CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
  -- Configuring incomplete, errors occurred!
  See also "C:/Users/Shub/AppData/Local/Temp/pip-install-tdd7o170/opencv-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 Win64

    could not find any instance of Visual Studio.



  -- Configuring incomplete, errors occurred!
  See also "C:/Users/Shub/AppData/Local/Temp/pip-install-tdd7o170/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
  Not searching for unused variables given on the command line.
  -- The C compiler identification is unknown
  CMake Error at CMakeLists.txt:3 (ENABLE_LANGUAGE):
    The CMAKE_C_COMPILER:

      cl

    is not a full path and was not found in the PATH.

    To use the NMake generator with Visual C++, cmake must be run from a shell
    that can use the compiler cl from the command line.  This environment is
    unable to invoke the cl compiler.  To fix this problem, run cmake from the
    Visual Studio Command Prompt (vcvarsall.bat).

    Tell CMake where to find the compiler by setting either the environment
    variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
    the compiler, or to the compiler name if it is in the PATH.


  -- Configuring incomplete, errors occurred!
  See also "C:/Users/Shub/AppData/Local/Temp/pip-install-tdd7o170/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
  See also "C:/Users/Shub/AppData/Local/Temp/pip-install-tdd7o170/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeError.log".
  Not searching for unused variables given on the command line.
  -- The C compiler identification is unknown
  CMake Error at CMakeLists.txt:3 (ENABLE_LANGUAGE):
    The CMAKE_C_COMPILER:

      cl

    is not a full path and was not found in the PATH.

    To use the JOM generator with Visual C++, cmake must be run from a shell
    that can use the compiler cl from the command line.  This environment is
    unable to invoke the cl compiler.  To fix this problem, run cmake from the
    Visual Studio Command Prompt (vcvarsall.bat).

    Tell CMake where to find the compiler by setting either the environment
    variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
    the compiler, or to the compiler name if it is in the PATH.


  -- Configuring incomplete, errors occurred!
  See also "C:/Users/Shub/AppData/Local/Temp/pip-install-tdd7o170/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
  See also "C:/Users/Shub/AppData/Local/Temp/pip-install-tdd7o170/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeError.log".


  ...

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

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

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

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

  ********************************************************************************
  ----------------------------------------
  ERROR: Failed building wheel for opencv-python
Failed to build opencv-python
ERROR: Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly

C:\Windows\system32>

I have visual studio 2019 installed, installed c++ build tools, as well as pip and wheel but it's not able to detect visual studio for some reason. I have restarted my computer after the install as well. Not sure how to resolve

  • Python 3.9 has only just been released, and many projects do not yet have binary wheels available. However, a 3rd party Windows wheel site does have these built, see the duplicate. – Martijn Pieters Oct 08 '20 at 15:43
  • 2
    And I've checked, Gohlke has the opencv wheel built: https://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv. Install it with `pip install pipwin` then `pipwin install opencv` (I *think*, Gohlke uses `opencv` as the key, while the wheel is build for `opencv-python`, it is up to the exact implementation of `pipwin` if it'll let you use one or the other name). – Martijn Pieters Oct 08 '20 at 15:44
  • @MartijnPieters thanks a lot! Worked for me, but with `pipwin install opencv-python` – Diogo Silva Oct 16 '20 at 14:33
  • I had the same problem, i downgraded to Python-3.7.9 and OpenCv installed on it without any issue. – Huzaifa Oct 29 '20 at 14:41

1 Answers1

0

just had the exact same problem :D for me it worked to go to the visual studio installer, select modify at the visual studio version and then install the "Desktop development with C++" then try to install it again