OpenCV:分段错误(核心转储)

sub*_*ker 5 python opencv segmentation-fault

这是非常基本的程序:

import numpy
import cv2

img = cv2.imread('watch.jpg', cv2.IMREAD_GRAYSCALE)

cv2.imshow('image', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Run Code Online (Sandbox Code Playgroud)

当我写时python3 opencv.py,出现以下错误:

QObject::moveToThread: Current thread (0x2e43c30) is not the object's thread (0x2ee1060).

Cannot move to target thread (0x2e43c30)

Segmentation fault (core dumped)
Run Code Online (Sandbox Code Playgroud)

由于包含imshow(). 使用绘图matplotlib效果很好。使用 python2 也会产生相同的错误。

我已经使用以下方法安装/重新安装了 opencv:

sudo pip3 install opencv-python

sudo apt install python-opencv
Run Code Online (Sandbox Code Playgroud)

在搜索解决方案时尝试安装 contrib 包

sudo pip3 install opencv-contrib-python
Run Code Online (Sandbox Code Playgroud)

即尝试了两种不同的虚拟环境condavenv(显然它不会解决问题)

这是使用gdb python3>调试的结果run opencv.py

Starting program: /home/subtleseeker/virtualenvironment/pp/bin/python3 openCV.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff3bac700 (LWP 13322)]
[New Thread 0x7ffff33ab700 (LWP 13323)]
[New Thread 0x7fffeebaa700 (LWP 13324)]
QObject::moveToThread: Current thread (0xee9360) is not the object's thread (0xf867a0).
Cannot move to target thread (0xee9360)


Thread 1 "python3" received signal SIGSEGV, Segmentation fault.
0x00007fffe24d41ce in xcb_send_request_with_fds64 ()
   from /usr/lib/x86_64-linux-gnu/libxcb.so.1
Run Code Online (Sandbox Code Playgroud)

我正在使用 Kubuntu 17.04。我真的别无选择,还有什么可以尝试的。任何帮助是极大的赞赏。