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安裝成功的信息提示
問題再現(xiàn)當安裝完cmake之后,我又重新使用pip安裝opencv,但是依舊沒能安裝成功 ?? 依然還是與問題一同樣的報錯。于是,我又重新查閱網上資料,得到的解決方案是,需要更新pip工具包。
解決方案二
需要修復pip。
修復語句
python -m ensurepip
安裝成功后,再重新更新pip工具包
python -m pip install --upgrade pip setuptools wheel
這時候發(fā)現(xiàn)pip工具包已經更新成功。
緊接著,再次嘗試更新opencv。
pip install opencv-python -i https://pypi.doubanio.com/simple/
發(fā)現(xiàn)opencv也已經安裝成功!問題解決~ ??
到此這篇關于pycharm安裝opencv-python報錯的解決的文章就介紹到這了,更多相關pycharm安裝opencv-python報錯內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
用Python的Flask框架結合MySQL寫一個內存監(jiān)控程序
這篇文章主要介紹了用Python的Flask框架結合MySQL些一個內存監(jiān)控程序的例子,并且能將結果作簡單的圖形化顯示,需要的朋友可以參考下2015-11-11詳解Python 2.6 升級至 Python 2.7 的實踐心得
本篇文章主要介紹了詳解Python 2.6 升級至 Python 2.7 的實踐心得,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-04-04Python 實現(xiàn)輸入任意多個數(shù),并計算其平均值的例子
今天小編就為大家分享一篇Python 實現(xiàn)輸入任意多個數(shù),并計算其平均值的例子,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-07-07