Kali Linux pyqt5 執行報錯xcb
阿新 • • 發佈:2021-02-06
目錄
Kali Linux pyqt5 執行報錯問題
問題現象
在環境上裝完PyQt5 以及pyqt5-tools 這兩個包後,執行程式報錯
qt.qpa.plugin Could not load the Qt platform plugin "xcb" in "" even though it was found.
在網上找了很久,綜合參考網友的問題和解決方法最終先搞掂
參考過的文章:(不過沒有解決當前的問題, 其他人也可以試試)
https://blog.csdn.net/zhanghm1995/article/details/106474505
https://blog.csdn.net/jiguangfan/article/details/86490160
解決方案
通過參考這篇文章找到解決方法
https://blog.csdn.net/u012768805/article/details/98756925
~/bashrc 中新增export QT_DEBUG_PLUGINS=1 (不確定是否有用, 可自行嘗試)
在庫檔案目錄中找到libqxcb.so
cd /usr/local/lib/python3.9/dist-packages/PyQt5/Qt/plugins/platforms
執行命令
ldd libqxcb.so
檢視關聯內容,如下: libxcb-util.so.1 => not found
通過搜尋結合這位老哥的文章(
缺少libxcb-util1
庫)
https://www.cnblogs.com/mariocanfly/p/14061631.html
通過命令安裝:
apt install libxcb-util1
Pycharm 執行程式
# -*- coding: utf-8 -*- import sys from PyQt5.QtWidgets import QApplication, QMainWindow if __name__ == '__main__': app = QApplication(sys.argv) w = QMainWindow() w.setWindowTitle('my first app') w.resize(400, 300) w.move(300, 300) w.show() sys.exit(app.exec_())