pycharm安装opencv-python报错的解决

 更新时间:2023年07月04日 15:24:02   作者:dsdasun  
本文主要介绍了pycharm安装opencv-python报错的解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

问题一 通过pycharm中的Terminal窗口安装opencv-python错误如下:

上图所示为部分错误,全部错误如下:

  Building wheel for opencv-contrib-python (PEP 517) ... error
  ERROR: Complete output from command 'D:\anzhuanglujing\Anaconda\python.exe' 'D:\anzhuanglujing\Anaconda\lib\site
-packages\pip\_vendor\pep517\_in_process.py' build_wheel 'C:\Users\Administrator\AppData\Local\Temp\tmpjqvqd9_8':
  ERROR: 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/Administrator/AppData/Local/Temp/pip-install-bc_r227f/opencv-contrib-python/_cmake_test_compi
le/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/Administrator/AppData/Local/Temp/pip-install-bc_r227f/opencv-contrib-python/_cmake_test_compi
le/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/Administrator/AppData/Local/Temp/pip-install-bc_r227f/opencv-contrib-python/_cmake_test_compi
le/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/Administrator/AppData/Local/Temp/pip-install-bc_r227f/opencv-contrib-python/_cmake_test_compi
le/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/Administrator/AppData/Local/Temp/pip-install-bc_r227f/opencv-contrib-python/_cmake_test_compi
le/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/Administrator/AppData/Local/Temp/pip-install-bc_r227f/opencv-contrib-python/_cmake_test_compi
le/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/Administrator/AppData/Local/Temp/pip-install-bc_r227f/opencv-contrib-python/_cmake_test_compi
le/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/Administrator/AppData/Local/Temp/pip-install-bc_r227f/opencv-contrib-python/_cmake_test_compi
le/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/Administrator/AppData/Local/Temp/pip-install-bc_r227f/opencv-contrib-python/_cmake_test_compi
le/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.7 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
 

解决办法:升级pip版本,命令如下:python -m pip install --upgrade pip

升级后显示如下图所示:

安装opencv-python,

命令如下:pip install opencv-contrib-python -ihttps://pypi.tuna.tsinghua.edu.cn/simple

安装成功后结果如下图所示:

问题二用默认源安装库,一般来说下载的速度很慢,更何况opencv这种比较大的库,所以我使用的是豆瓣源(当然你也可以使用清华源…)

安装语句

pip install opencv-python -i https://pypi.doubanio.com/simple/

报错

解决方案一

遇到这个问题之后,我在网上查阅解决方法,有文章说是需要安装cmake(但是其实没有实际解决,严格按照文章步骤操作,最后将会成功安装opencv)

安装语句

pip install cmake -i https://pypi.doubanio.com/simple/

以上是cmake安装成功的信息提示

问题再现当安装完cmake之后,我又重新使用pip安装opencv,但是依旧没能安装成功 😦 依然还是与问题一同样的报错。于是,我又重新查阅网上资料,得到的解决方案是,需要更新pip工具包。

解决方案二

需要修复pip。

修复语句

python -m ensurepip

安装成功后,再重新更新pip工具包

python -m pip install --upgrade pip setuptools wheel

这时候发现pip工具包已经更新成功。

紧接着,再次尝试更新opencv。

pip install opencv-python -i https://pypi.doubanio.com/simple/

发现opencv也已经安装成功!问题解决~ 😃

 到此这篇关于pycharm安装opencv-python报错的解决的文章就介绍到这了,更多相关pycharm安装opencv-python报错内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

相关文章

  • 使用Python快速提取PPT中的文本内容的代码示例

    使用Python快速提取PPT中的文本内容的代码示例

    本文将介绍如何使用Python程序提取PowerPoint演示文稿中的文本内容,包括幻灯片中的主体文本、幻灯片备注文本以及幻灯片,文中通过代码示例给大家介绍的非常详细,具有一定的参考价值,需要的朋友可以参考下
    2024-03-03
  • 详解如何在Python中有效调用JavaScript

    详解如何在Python中有效调用JavaScript

    JavaScript和Python都是极为流行的编程语言,并在前端开发和后端开发领域扮演着重要的角色,那么Python如何更好的契合JavaScript呢,下面就跟随小编一起学习一下吧
    2024-02-02
  • Python中的time模块与datetime模块用法总结

    Python中的time模块与datetime模块用法总结

    Python中内置的各项时间日期函数几乎都来自于time和datetime这两个模块,下面整理了Python中的time模块与datetime模块用法总结,需要的朋友可以参考下
    2016-06-06
  • python的turtle库使用详解

    python的turtle库使用详解

    在本篇文章里小编给大家分享了关于python的turtle库相关知识点以及使用方法,需要的朋友们跟着学习下。
    2019-05-05
  • python自动发邮件库yagmail的示例代码

    python自动发邮件库yagmail的示例代码

    本篇文章主要介绍了python自动发邮件库yagmail的示例代码,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2018-02-02
  • Python实现读取邮箱中的邮件功能示例【含文本及附件】

    Python实现读取邮箱中的邮件功能示例【含文本及附件】

    这篇文章主要介绍了Python实现读取邮箱中的邮件功能,可读取邮件文本及附件的功能,涉及Python针对邮件的获取、分析、保存等相关操作技巧,需要的朋友可以参考下
    2017-08-08
  • pytorch如何获得模型的计算量和参数量

    pytorch如何获得模型的计算量和参数量

    这篇文章主要介绍了pytorch如何获得模型的计算量和参数量操作,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教
    2021-05-05
  • python实现简单的计算器功能

    python实现简单的计算器功能

    这篇文章主要为大家详细介绍了python实现简单的计算器功能,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2022-07-07
  • Python创建xml的方法

    Python创建xml的方法

    这篇文章主要介绍了Python创建xml的方法,实例分析了Python操作XML文件的技巧,具有一定参考借鉴价值,需要的朋友可以参考下
    2015-03-03
  • python实现在sqlite动态创建表的方法

    python实现在sqlite动态创建表的方法

    这篇文章主要介绍了python实现在sqlite动态创建表的方法,涉及Python操作SQLite数据库创建数据表的技巧,具有一定参考借鉴价值,需要的朋友可以参考下
    2015-05-05

最新评论