之前已经安装好qt运行代码也没问题,后来移动了一下环境和代码位置,再运行就会报错如下:
报错:
Cannot move to target thread (0x257a660)
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/data/xx/xx/venv/lib/python3.6/site-packages/cv2/qt/plugins" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: xcb, eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl.
Process finished with exit code 134 (interrupted by signal 6: SIGABRT)
解决方法:需要把qt相关库libqxcb.so添加到环境变量中
具体操作的话就是在运行的.py文件前添加以下内容:
envpath = '/data/xx/xx/venv/lib/python3.6/site-packages/cv2/qt/plugins/platforms'
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = envpath
试试吧~~