pycharm安裝opencv-python報(bào)錯(cuò)的解決
問題一 通過pycharm中的Terminal窗口安裝opencv-python錯(cuò)誤如下:
上圖所示為部分錯(cuò)誤,全部錯(cuò)誤如下:
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
解決辦法:升級(jí)pip版本,命令如下:python -m pip install --upgrade pip
升級(jí)后顯示如下圖所示:
安裝opencv-python,
命令如下:pip install opencv-contrib-python -ihttps://pypi.tuna.tsinghua.edu.cn/simple
安裝成功后結(jié)果如下圖所示:
問題二用默認(rèn)源安裝庫(kù),一般來說下載的速度很慢,更何況opencv這種比較大的庫(kù),所以我使用的是豆瓣源(當(dāng)然你也可以使用清華源…)
安裝語(yǔ)句
pip install opencv-python -i https://pypi.doubanio.com/simple/
報(bào)錯(cuò)
解決方案一
遇到這個(gè)問題之后,我在網(wǎng)上查閱解決方法,有文章說是需要安裝cmake(但是其實(shí)沒有實(shí)際解決,嚴(yán)格按照文章步驟操作,最后將會(huì)成功安裝opencv)
安裝語(yǔ)句
pip install cmake -i https://pypi.doubanio.com/simple/
以上是cmake安裝成功的信息提示
問題再現(xiàn)當(dāng)安裝完cmake之后,我又重新使用pip安裝opencv,但是依舊沒能安裝成功 ?? 依然還是與問題一同樣的報(bào)錯(cuò)。于是,我又重新查閱網(wǎng)上資料,得到的解決方案是,需要更新pip工具包。
解決方案二
需要修復(fù)pip。
修復(fù)語(yǔ)句
python -m ensurepip
安裝成功后,再重新更新pip工具包
python -m pip install --upgrade pip setuptools wheel
這時(shí)候發(fā)現(xiàn)pip工具包已經(jīng)更新成功。
緊接著,再次嘗試更新opencv。
pip install opencv-python -i https://pypi.doubanio.com/simple/
發(fā)現(xiàn)opencv也已經(jīng)安裝成功!問題解決~ ??
到此這篇關(guān)于pycharm安裝opencv-python報(bào)錯(cuò)的解決的文章就介紹到這了,更多相關(guān)pycharm安裝opencv-python報(bào)錯(cuò)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- python?pycharm中使用opencv時(shí)沒有代碼自動(dòng)補(bǔ)全提示的解決方案
- Pycharm快速安裝OpenCV的詳細(xì)操作步驟
- 在PyCharm搭建OpenCV-python的環(huán)境的詳細(xì)過程
- 教你如何在pycharm中安裝opencv,tensorflow,keras
- Pycharm配置opencv與numpy的實(shí)現(xiàn)
- 詳解pycharm的python包opencv(cv2)無代碼提示問題的解決
- python使用pycharm環(huán)境調(diào)用opencv庫(kù)
- pycharm運(yùn)行OpenCV項(xiàng)目踩坑記錄
相關(guān)文章
用Python的Flask框架結(jié)合MySQL寫一個(gè)內(nèi)存監(jiān)控程序
這篇文章主要介紹了用Python的Flask框架結(jié)合MySQL些一個(gè)內(nèi)存監(jiān)控程序的例子,并且能將結(jié)果作簡(jiǎn)單的圖形化顯示,需要的朋友可以參考下2015-11-11詳解Python 2.6 升級(jí)至 Python 2.7 的實(shí)踐心得
本篇文章主要介紹了詳解Python 2.6 升級(jí)至 Python 2.7 的實(shí)踐心得,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-04-04Tensorflow簡(jiǎn)單驗(yàn)證碼識(shí)別應(yīng)用
這篇文章主要為大家詳細(xì)介紹了Tensorflow簡(jiǎn)單驗(yàn)證碼識(shí)別應(yīng)用的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-05-05python構(gòu)建基礎(chǔ)的爬蟲教學(xué)
在本篇內(nèi)容里小編給大家分享的是關(guān)于python構(gòu)建基礎(chǔ)的爬蟲教學(xué)內(nèi)容,需要的朋友們學(xué)習(xí)下。2018-12-12linux環(huán)境中沒有網(wǎng)絡(luò)怎么下載python
在本篇文章里小編給大家分享了關(guān)于linux環(huán)境中沒有網(wǎng)絡(luò)怎么下載python的相關(guān)知識(shí)點(diǎn)內(nèi)容,需要的朋友們參考下。2019-07-07python編程培訓(xùn) python培訓(xùn)靠譜嗎
現(xiàn)在大家都知道,比較火的編程語(yǔ)言就是python了,很多朋友都想學(xué)習(xí)python編程,想上一個(gè)好的python培訓(xùn)班,小編今天給大家全面分析一下關(guān)于python編程培訓(xùn)方面的問題,希望能給你答疑解惑。2018-01-01Python 實(shí)現(xiàn)輸入任意多個(gè)數(shù),并計(jì)算其平均值的例子
今天小編就為大家分享一篇Python 實(shí)現(xiàn)輸入任意多個(gè)數(shù),并計(jì)算其平均值的例子,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-07-07解決Python獲取字典dict中不存在的值時(shí)出錯(cuò)問題
今天小編就為大家分享一篇解決Python獲取字典dict中不存在的值時(shí)出錯(cuò)問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-10-10