Linux下安装python-opencv ,亲测可用

时间:2021-02-14 17:28:05

背景:

刚开始安装好Ubuntu16.04系统后,便安装了pip,直接使用pip进行安装opencv

pip install opencv-python

再使用

import cv2

进行检验发现可以通过,就以为安装成功了。后来直到我使用cv2.imshow()函数的时候发现图像出不来,并且提示以下错误的时候才知道自己安装的opencv有问题了。
OpenCV 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 cvNamedWindow, 
file /home/aborn/software/opencv-2.4.1/modules/highgui/src/window.cpp, line 598

解决办法如下:

step1:卸载已安装的opencv-python

pip uninstall opencv-python
step2: 安装gtk2.0

ubuntu安装GTK2.0

step3: 安装opencv

Linux下安装python-opencv