北纬的北 發表於 2021-4-30 14:15:00

Deepin下搭建pyqt5开发环境——基于vscode

<p>1.安装pyqt5</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">sudo</span> apt-get <span style="color: rgba(0, 0, 255, 1)">install</span> pyqt5*</pre>
</div>
<p>2.安装QT5开发工具,里面包含了Qt Designer等工具</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">sudo</span> apt-get <span style="color: rgba(0, 0, 255, 1)">install</span> qttools5-dev-tools</pre>
</div>
<p>3.打开vscode,搜索pyqt,安装PYQT Integration插件</p>
<p><img src="https://img2020.cnblogs.com/blog/1183108/202104/1183108-20210430140141913-1443274141.png"></p>
<p>&nbsp;</p>
<p>4.点击小齿轮--&gt;扩展设置,对PYQT Integration插件进行设置</p>
<p><img src="https://img2020.cnblogs.com/blog/1183108/202104/1183108-20210430140306670-391138685.png"></p>
<p>&nbsp;</p>
<p>5.在Pyqt-integration › Qtdesigner: Path中,增加QT designer的路径</p>
<div class="cnblogs_code">
<pre>/usr/lib/x86_64-linux-gnu/qt5/bin/designer</pre>
</div>
<p>&nbsp;<img src="https://img2020.cnblogs.com/blog/1183108/202104/1183108-20210430140410751-2037010104.png"></p>
<p>这样完成了对Deepin下pyqt5开发环境的搭建</p>
<p>&nbsp;</p>
<p>可能出现的错误提示:</p>
<p>错误提示1</p>
<div class="cnblogs_code">
<pre>Error: Command failed: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">pyuic5</span><span style="color: rgba(128, 0, 0, 1)">"</span> -p <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">/home/nexfia/Documents/PyQt5 Project/PDFDecryptionTool/WinUI.ui</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">

qt.qpa.plugin: Could not load the Qt platform plugin </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">xcb</span><span style="color: rgba(128, 0, 0, 1)">"</span> <span style="color: rgba(0, 0, 255, 1)">in</span> <span style="color: rgba(128, 0, 0, 1)">""</span><span style="color: rgba(0, 0, 0, 1)"> 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</span>-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-<span style="color: rgba(0, 0, 0, 1)">glx, webgl, xcb.

Aborted</span></pre>
</div>
<p>错误提示2</p>
<div class="cnblogs_code">
<pre>qt.qpa.plugin: Could not load the Qt platform plugin <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">xcb</span><span style="color: rgba(128, 0, 0, 1)">"</span> <span style="color: rgba(0, 0, 255, 1)">in</span> <span style="color: rgba(128, 0, 0, 1)">""</span><span style="color: rgba(0, 0, 0, 1)"> 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</span>-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.</pre>
</div>
<p>错误提示1是使用PYQT Integration插件对.ui文件进行预览时提示的。</p>
<p>错误提示2时python程序导入了pyqt5,运行程序时提示的</p>
<p><strong>这2个错误的原因在于你装了多个pyqt5</strong></p>
<p>一个可能是使用 pip 安装了一个</p>
<div class="cnblogs_code">
<pre>pip3 <span style="color: rgba(0, 0, 255, 1)">install</span> pyqt5</pre>
</div>
<p>另一个可能是使用我上面的命令安装了一个</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">sudo</span> apt-get <span style="color: rgba(0, 0, 255, 1)">install</span> pyqt5*</pre>
</div>
<p>导致不知道用那个xcb</p>
<p><strong>解决方法是将使用pip安装的pyqt5卸载掉</strong></p>
<div class="cnblogs_code">
<pre>pip3 uninstall pyqt5</pre>
</div>
<p>&nbsp;</p><br><br>
来源:https://www.cnblogs.com/syxy/p/14721832.html
頁: [1]
查看完整版本: Deepin下搭建pyqt5开发环境——基于vscode