无法为使用PEP 517且无法直接安装的opencv python构建控制盘

无法为使用PEP 517且无法直接安装的opencv python构建控制盘,python,windows,opencv,cmake,pip,Python,Windows,Opencv,Cmake,Pip,我正在尝试在windows上安装opencv python,但在运行pip install opencv python命令后,我不断出现以下错误:错误:无法为使用PEP 517的opencv python构建控制盘,无法直接安装 我使用的是python版本3.9.0和pip版本PIP20.2.4 我已经尝试升级我的pip版本以及运行pip安装--升级pip设置工具轮子,就像在类似的线程上一样,但这些似乎都不能解决问题 运行命令后的完整控制台输出: Collecting opencv-py

我正在尝试在windows上安装opencv python,但在运行
pip install opencv python
命令后,我不断出现以下错误:
错误:无法为使用PEP 517的opencv python构建控制盘,无法直接安装

我使用的是python版本3.9.0和pip版本PIP20.2.4

我已经尝试升级我的pip版本以及运行
pip安装--升级pip设置工具轮子
,就像在类似的线程上一样,但这些似乎都不能解决问题

运行命令后的完整控制台输出:

    Collecting opencv-python
  Downloading opencv-python-4.4.0.44.tar.gz (88.9 MB)
     |████████████████████████████████| 88.9 MB 3.3 MB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting numpy>=1.17.3
  Downloading numpy-1.19.2.zip (7.3 MB)
     |████████████████████████████████| 7.3 MB 6.4 MB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Building wheels for collected packages: opencv-python, numpy
  Building wheel for opencv-python (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\users\david\appdata\local\programs\python\python39\python.exe' 'c:\users\david\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\pep517\_in_process.py' build_wheel 'C:\Users\David\AppData\Local\Temp\tmpl1finc77'
       cwd: C:\Users\David\AppData\Local\Temp\pip-install-gfwb0hqn\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/David/AppData/Local/Temp/pip-install-gfwb0hqn/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/David/AppData/Local/Temp/pip-install-gfwb0hqn/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/David/AppData/Local/Temp/pip-install-gfwb0hqn/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
  See also "C:/Users/David/AppData/Local/Temp/pip-install-gfwb0hqn/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/David/AppData/Local/Temp/pip-install-gfwb0hqn/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
  See also "C:/Users/David/AppData/Local/Temp/pip-install-gfwb0hqn/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeError.log".


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



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



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



  --------------------------------------------------------------------------------
  -- 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
  Building wheel for numpy (PEP 517) ... done
  Created wheel for numpy: filename=numpy-1.19.2-cp39-cp39-win_amd64.whl size=4816060 sha256=18bd09a9c5e107a2e44f8466057d0b423a244fb84949a6d5a6d88534a58e1e4a
  Stored in directory: C:\Users\David\AppData\Local\Temp\pip-ephem-wheel-cache-v6mmdzxn\wheels\a3\17\dd\f2dba23a35bb6008732772ccfb13d3d0e537fbc6919ce6862b
Successfully built numpy
Failed to build opencv-python
ERROR: Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly

任何形式的帮助都将不胜感激,谢谢

对于
opencv-Python
,还没有预先构建的Python 3.9二进制程序。要从源代码处编译,必须安装生成工具(Visual Studio 15 2017),如错误所示:

  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/

opencvpython
python3.9轮子跟踪问题:

Well“找不到任何visualstudio实例”似乎很清楚。安装Visual Studio编译器。没错,我已经安装了VS 2017,我认为这可能是问题所在,但没有合适的构建工具。在使用那些我已经设法使pip安装工作正常的工具重新安装之后,谢谢。请确保在安装Visual Studio时选中“工作负载>Python环境”。