cv2.imshow这个函数出错,如下No protocol specified qt.qpa.xcb: could not connect to display :0
时间: 2023-11-27 17:40:54 浏览: 189
这个错误通常发生在使用ssh远程连接到另一台机器上时,如果你想在远程连接的机器上显示图像,需要在运行ssh命令时加上-X参数,例如:
```
ssh -X user@remote_ip
```
这样就可以在远程机器上显示图像了。如果还是出现问题,可以尝试在远程机器上安装x11-xserver-utils并运行xhost +local:来允许本地用户访问X服务器。
相关问题
qt.qpa.xcb: could not connect to display qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
这个错误是由于远程连接服务器时无法直接传回图形界面导致的。这个错误通常在使用Qt库时出现,比如在代码中使用了cv.imshow()函数。解决这个问题的方法有两种:
1. 不要求传回图像且不报错的解决方案是注释掉与cv.imshow()相关的代码。这样可以避免出现错误。
2. 另一种解决方案是通过修改配置文件来解决。你可以使用以下命令打开配置文件:
sudo vim /etc/profile
在打开的文件中,你可以添加以下内容来设置环境变量:
export QT_QPA_PLATFORM_PLUGIN_PATH=/usr/local/qt5pi/plugins/platforms
保存并退出文件后,重新启动你的应用程序,这样应该就能够解决这个错误了。
请注意,这些解决方案适用于不同的情况,具体的解决方法可能因个人环境而异。建议你根据自己的情况选择适合的解决方案。
#### 引用[.reference_title]
- *1* [qt.qpa.xcb: could not connect to display qt.qpa.plugin: Could not load the Qt platform plugin “xcb](https://blog.csdn.net/qq_43248104/article/details/131381976)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [解决qt.qpa.xcb: could not connect to display问题](https://blog.csdn.net/every_step/article/details/120640384)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [远程服务器时Ubuntu报错:qt.qpa.xcb: could not connect to display](https://blog.csdn.net/liuyang_xyz/article/details/126520299)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
qt.qpa.xcb: could not connect to display :0.0 qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
这个错误是由于远程连接服务器时无法直接传回图形界面导致的。这个错误通常在使用Qt库时出现,比如在代码中使用了cv.imshow()函数。解决这个问题的方法是注释掉相关的代码,不要使用cv.imshow()函数。另外,你可以尝试在终端中输入sudo vim /etc/profile命令来编辑配置文件,然后添加一行代码来解决这个问题。
#### 引用[.reference_title]
- *1* [qt.qpa.xcb: could not connect to display qt.qpa.plugin: Could not load the Qt platform plugin “xcb](https://blog.csdn.net/qq_43248104/article/details/131381976)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [解决qt.qpa.xcb: could not connect to display问题](https://blog.csdn.net/every_step/article/details/120640384)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [远程服务器时Ubuntu报错:qt.qpa.xcb: could not connect to display](https://blog.csdn.net/liuyang_xyz/article/details/126520299)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文