通过Conda安装OpenCV时发生Gtk错误

时间:2019-04-23 02:51:16

标签: python-3.x opencv gtk conda jupyter-lab

我试图在conda环境中的jupyter实验室中运行以下代码,然后出现一些错误

import numpy as np
import cv2 as cv

img = cv.imread('image01.png', 0)
cv.imshow('image', img)
cv.waitKey(0)
cv.destroyAllWindows()
---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
<ipython-input-2-9c9fc790a80e> in <module>
      1 img = cv.imread('image01.png', 0)
----> 2 cv.imshow('image', img)
      3 cv.waitKey(0)
      4 cv.destroyAllWindows()

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'

这是我拥有的工具版本:

  • Ubuntu 18.04
  • python3 --versionPython 3.6.8 :: Anaconda custom (64-bit)
  • pip --vesionpip 19.0.3 from /home/me/.local/lib/python3.6/site-packages/pip (python 3.6)
  • conda --versionconda 4.6.14

我的opencv版本是3.4.2,它来自conda-forge频道

如果您有兴趣查看完整的conda环境,请为列表提供一个pastebin:

https://pastebin.com/FYvmErZg

我安装了libgtk2.0-devpkg-config,但是我不知道如何使用cmake,特别是当通过conda安装软件包(opencv)而不是从源代码构建时。

我还尝试安装此issue中建议的一些软件包。哪个是

# Should work in any linux conda install
conda install -c loopbio -c conda-forge -c pkgw-forge ffmpeg-feature ffmpeg gtk2 opencv

注意::我无法安装ffmpeg-feature

0 个答案:

没有答案