您尚未登录。

#1 2023-01-25 19:31:47

lylkr
会员
注册时间: 2023-01-07
帖子: 16

求助 qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""

pycharm   opencv

安装成功后,输入cv2.没有代码补全提示,以手动完全输入并正常运行
但cv2.imshow  提示Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.



按照网上的办法将 site-packages/cv2路径添加到 解释器路径 中代码补全功能正常了,
但 cv2.imshou报错
qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

请问如何解决

离线

#2 2023-01-25 19:41:04

BRS5672023
会员
注册时间: 2020-07-07
帖子: 92

Re: 求助 qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""

感觉像是qt环境变量的问题。。

QT_QPA_PLATFORM="wayland;xcb"

你看这么写能不能解决这个问题。。

离线

#3 2023-01-25 22:29:54

lylkr
会员
注册时间: 2023-01-07
帖子: 16

Re: 求助 qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""

wayland改为x11就不再出现提示Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.这个警告了


qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
这个错误仍然没能解决

离线

#4 2023-01-25 23:37:18

lylkr
会员
注册时间: 2023-01-07
帖子: 16

Re: 求助 qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""

删除这个路径site-packages/cv2
莫名奇妙的好了,能代码补全了,也能cv2.imshow了

离线

#5 2023-01-26 11:50:22

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 8,431
个人网站

Re: 求助 qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""

你的 site-packages/cv2 是在哪里的, /usr/lib 还是 ~/.local/lib?

离线

#6 2023-01-27 01:30:56

lylkr
会员
注册时间: 2023-01-07
帖子: 16

Re: 求助 qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""

依云 说:

你的 site-packages/cv2 是在哪里的, /usr/lib 还是 ~/.local/lib?

分别新建了两个测试项目
一个在/usr/lib下
一个在PycharmProjects/pythonProject/venv下
都有这个问题

我现在的解决方法是,用哪个路径就i将哪个路径下的site-packages/cv2加入到 解释器路径 中,实现cv2.的代码自动补全(因为新建的项目cv2.不能自动代码补全),但此时cv2.imshow会报错
然后再删除site-packages/cv2这个路径,让cv2.imshow正常显示不报错,而此时的代码自动补全仍然能正常工作

不知为啥

离线

页脚