1. 程式人生 > >Ubuntu16.04 OpenCV error: the function is not implemented

Ubuntu16.04 OpenCV error: the function is not implemented

我用py執行程式碼的時候,報錯如下:

Traceback (most recent call last):
  File "/home/ai/PythonProjects/tf/vehicle_nums.py", line 13, in <module>
    cv2.imshow("Capturing", gray)
cv2.error: OpenCV(3.4.2) /tmp/build/80754af9/opencv-suite_1535558553474/work/modules/highgui/src/window.cpp:632: error: (-2: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 function 'cvShowImage'

我網上找了一下,都說是要解除安裝,比如這裡,命令提示要重新re-runcmake, 但是我的opencv原始碼安裝完之後就刪除了。而且我opencv-C++介面是可以用的。所以我覺得問題並沒有出現在這裡。 我首先查看了我c++opencv的版本

$ pkg-config --modversion opencv
3.4.1

我用conda list查看了我python-opencv的版本,是3.4.2,我覺得原因可能出在這裡,所以我解除安裝了anaconda中的opencv

$ conda uninstall py-opencv
$ pip3 install opencv-python==3.4.1
Collecting opencv-python==3.4.1
  Could not find a version that satisfies the requirement opencv-python==3.4.1 (from versions: 3.1.0.4, 3.1.0.5, 3.2.0.6, 3.2.0.7, 3.2.0.8, 3.3.0.9, 3.3.0.10, 3.3.1.11, 3.4.0.12, 3.4.0.14, 3.4.1.15, 3.4.2.16, 3.4.2.17, 3.4.3.18)
No matching distribution found for opencv-python==3.4.1
$ pip3 install opencv-python==3.4.1.15

然後程式就好了