1. 程式人生 > >python+opencv 問題解決方案,OpenCV Error: Unspecified error (The function is not implemented. Rebuild the

python+opencv 問題解決方案,OpenCV Error: Unspecified error (The function is not implemented. Rebuild the

系統Ubuntu 18.04 LTS

python 版本 Anaconda python3.6

採用conda install opencv後,呼叫opencv的函式時,出現錯誤:

 

OpenCV(3.4.1) Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvShowImage, file /opt/conda/conda-bld/opencv-suite_1530789967746/work/modules/highgui/src/window.cpp, line 636
Traceback (most recent call last):
  File "drawing.py", line 9, in <module>
    cv2.imshow("Canvas", canvas)
cv2.error: OpenCV(3.4.1) /opt/conda/conda-bld/opencv-suite_1530789967746/work/modules/highgui/src/window.cpp:636: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvShowImage

 

看過網上很多的方法,都沒有效果。後來通過這篇部落格,算是解決了我的問題:

https://blog.csdn.net/leviopku/article/details/79247236,感謝這位樓主!

具體就是通過這個命令來安裝opencv:

conda install --channel https://conda.anaconda.org/menpo opencv3

 

然而,這裡面還有一個問題是這樣安裝的版本是opencv3.1版本的,而我今天要用到的功能是opencv3.3以上版本才會有的。所以自己又折騰了一下,最後發現採用

pip install opencv-python

應該就可以安裝好,由於我採用pip安裝時候總是下載失敗,我就去pip的官網去下載了。我把網址貼在這裡

https://pypi.org/project/opencv-python/#files

從這裡下載好自己對應版本的opencv,然後採用cd到相應目錄,

pip install opencv_python-3.4.2.16-cp36-cp36m-manylinux1_x86_64.whl (我的版本) 就可以解決上述問題啦!

 

希望對有opencv高版本需求的小夥伴們有幫助!

轉載自:https://blog.csdn.net/fdd096030079/article/details/81156811

對自己有用的是:直接在終端,對應的操作環境中執行;  pip install opencv-python