这是我得到的确切错误.我的操作系统是 Ubuntu 16.10.
This is the exact error that I am getting. My OS is Ubuntu 16.10.
OpenCV 错误:未指定错误(该功能未实现.使用 Windows、GTK+ 2.x 或 Carbon 支持重建库.如果您在 Ubuntu 或 Debian 上,请安装 libgtk2.0-dev 和 pkg-config,然后重新运行 cmake 或配置脚本)在 cvShowImage,文件/feedstock_root/build_artefacts/work/opencv-3.1.0/modules/highgui/src/window.cpp,第 545 行回溯(最近一次通话最后):文件untitled.py",第 7 行,在cv2.imshow('图片',img)cv2.error:/feedstock_root/build_artefacts/work/opencv-3.1.0/modules/highgui/src/window.cpp:545: error: (-2) 功能没有实现.使用 Windows、GTK+ 2.x 或 Carbon 支持重建库.如果你在 Ubuntu 或 Debian 上,安装 libgtk2.0-dev 和 pkg-config,然后重新运行 cmake 或在函数 cvShowImage 中配置脚本
我的代码是:
import numpy as np
import cv2
# Load an color image in grayscale
img = cv2.imread('0002.png',0)
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
0002.png 是与程序位于同一目录中的图像.我首先用python 3.5安装了anaconda,然后我使用命令安装了opencv
0002.png is an image in the same directory as the program. I first installed anaconda with python 3.5, then I installed opencv by using the command
conda install -c conda-forge opencv
我安装了 libgtk2.0-dev,就像错误所说的那样,但我仍然得到同样的错误.任何帮助将非常感激.我已经尝试解决这个问题几个小时了.
I installed libgtk2.0-dev just as the error said to but I still get the same error. Any help would be much appreciated. I've been trying to solve this for several hours.
1.最简单的方法:
conda remove opencv
conda update conda
conda install --channel menpo opencv
或(对于 OpenCV 3.1):
or (for OpenCV 3.1) :
conda install -c menpo opencv3
2.如果你不想这样做,你可以尝试使用matplotlib.
2.And if u don't want to do this, you can try to use matplotlib .
import cv2
import matplotlib.pyplot as plt
img = cv2.imread('img.jpg',0)
plt.imshow(img, cmap='gray')
plt.show()
3.或者尝试使用选项 WITH_GTK=ON 自己构建库,或者类似的东西.
3.Or try to build library by your own with option WITH_GTK=ON , or smth like that.
更新 - 2019 年 6 月 18 日
Update - 18th Jun 2019
我的 Ubuntu(18.04.1 LTS) 系统上的 openCV 3.4.2 出现此错误,因为对 cv2.imshow 的方法调用失败.我正在使用蟒蛇.仅以下 2 个步骤帮助我解决了问题:
I got this error on my Ubuntu(18.04.1 LTS) system for openCV 3.4.2, as the method call to cv2.imshow was failing. I am using anaconda. Just the below 2 steps helped me resolve:
conda remove opencv
conda install -c conda-forge opencv=4.1.0
如果你用的是pip,可以试试
If you are using pip, you can try
pip install opencv-contrib-python
这篇关于OpenCV 在 Linux 上的 python 与 anaconda 无法正常工作.收到未实现 cv2.imshow() 的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
使用 python 解析非常大的 xml 文件时出现问题Troubles while parsing with python very large xml file(使用 python 解析非常大的 xml 文件时出现问题)
使用 Python 2 在 XML 中按属性查找所有节点Find all nodes by attribute in XML using Python 2(使用 Python 2 在 XML 中按属性查找所有节点)
Python - 如何解析 xml 响应并将元素值存储在变量中Python - How to parse xml response and store a elements value in a variable?(Python - 如何解析 xml 响应并将元素值存储在变量中?)
如何在 Python 中获取 XML 标记值How to get XML tag value in Python(如何在 Python 中获取 XML 标记值)
如何使用 ElementTree 正确解析 utf-8 xml?How to correctly parse utf-8 xml with ElementTree?(如何使用 ElementTree 正确解析 utf-8 xml?)
将 XML 从 URL 解析为 python 对象Parse XML from URL into python object(将 XML 从 URL 解析为 python 对象)