Deepin下搭建pyqt5開發環境——基於vscode


1.安裝pyqt5

sudo apt-get install pyqt5*

2.安裝QT5開發工具,里面包含了Qt Designer等工具

sudo apt-get install qttools5-dev-tools

3.打開vscode,搜索pyqt,安裝PYQT Integration插件

 

4.點擊小齒輪-->擴展設置,對PYQT Integration插件進行設置

 

5.在Pyqt-integration › Qtdesigner: Path中,增加QT designer的路徑

/usr/lib/x86_64-linux-gnu/qt5/bin/designer

 

這樣完成了對Deepin下pyqt5開發環境的搭建

 

可能出現的錯誤提示:

錯誤提示1

Error: Command failed: "pyuic5" -p "/home/nexfia/Documents/PyQt5 Project/PDFDecryptionTool/WinUI.ui"

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" 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: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

Aborted

錯誤提示2

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" 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: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

錯誤提示1是使用PYQT Integration插件對.ui文件進行預覽時提示的。

錯誤提示2時python程序導入了pyqt5,運行程序時提示的

這2個錯誤的原因在於你裝了多個pyqt5

一個可能是使用 pip 安裝了一個

pip3 install pyqt5

另一個可能是使用我上面的命令安裝了一個

sudo apt-get install pyqt5*

導致不知道用那個xcb

解決方法是將使用pip安裝的pyqt5卸載掉

pip3 uninstall pyqt5

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM