PyQt5:如何安装/运行 Qt 设计器

时间:2023-03-11
本文介绍了PyQt5:如何安装/运行 Qt 设计器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

现在感觉真的很愚蠢,但标题说明了一切:

Feeling really stupid, right now, but the title says it all:

如何启动 QtDesigner?

How do you start the QtDesigner?

我已经通过 pip 安装了 PyQt5 并且我相信已经将它的安装目录标识为

I've installed PyQt5 via pip and I believe to have identified the directory it's been installed in as

C:Users\%username%AppDataLocalProgramsPythonPython36Libsite-packagesPyQt5

现在呢?有很多 .pyd 文件,也有一些 .dll,但没有可执行文件(嗯,除了 ...site-packagesPyQt5Qtin 中的 QtWebEngineProcess.exe,但这听起来不像我要找的.

Now what? There are a lot of .pyd files, some .dll's, too, but nothing executable (well, except a QtWebEngineProcess.exe in ...site-packagesPyQt5Qtin, but that doesn't sound like what I'm looking for.

推荐答案

最新的 PyQt5 轮子(可以通过 pip 安装)只包含运行应用程序所需的内容,不包含开发工具.这适用于 PyQt 5.7 及更高版本.对于 PyQt 5.6 及更早的版本,还有一些适用于 Windows 的二进制包,其中还包含开发工具,这些仍然可以在 sourceforge.不过,PyQt 的维护者不打算进一步发布此类二进制包 - 现在只有运行时轮子可用,开发工具不会有官方轮子.

The latest PyQt5 wheels (which can be installed via pip) only contain what's necessary for running applications, and don't include the dev tools. This applies to PyQt versions 5.7 and later. For PyQt versions 5.6 and earlier, there are binary packages for Windows that also include the dev tools, and these are still available at sourceforge. The maintainer of PyQt does not plan on making any further releases of such binary packages, though - only the runtime wheels will now be made available, and there will be no official wheels for the dev tools.

鉴于此,有人创建了一个非官方的pyqt5-tools wheel(用于仅限 Windows).不过,这似乎还处于早期阶段,因此可能跟不上最近的 PyQt5 版本.这意味着它可能并不总是可以通过 pip 安装它.如果是这种情况,作为一种变通方法,可以将轮文件视为 zip 文件,并将内容提取到合适的位置.这应该允许您运行 pyqt5-tools/designer 文件夹中的 designer.exe 文件.

In light of this, someone has created an unofficial pyqt5-tools wheel (for Windows only). This appears to be in it's early stages, though, and so may not keep up with recent PyQt5 releases. This means that it may not always be possible to install it via pip. If that is the case, as a work-around, the wheel files can be treated as zip files and the contents extracted to a suitable location. This should then allow you to run the designer.exe file that is in the pyqt5-tools/designer folder.

最后,请注意,您还将在 sourceforge 中看到一些用于 PyQt5 的 zip 和 tar.gz 文件.但是,这些只包含源代码,所以除非你打算自己编译 PyQt5,否则对你毫无用处.并且要明确一点:从源代码编译仍然不会为您提供所有 Qt 开发工具.如果您走这条路,您还需要单独安装整个 Qt 开发工具包(然后为您提供开发工具).

Finally, note that you will also see some zip and tar.gz files at sourceforge for PyQt5. These only contain the source code, though, so will be no use to you unless you intend to compile PyQt5 yourself. And just to be clear: compiling from source still would not give you all the Qt dev tools. If you go down that route, you would need to install the whole Qt development kit separately as well (which would then get you the dev tools).

这篇关于PyQt5:如何安装/运行 Qt 设计器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!