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 
    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

然后程序就好了

你可能感兴趣的:(opencv,Linux,LInux问题与环境配置)