PyQt5:如何 install/run Qt Designer

PyQt5: How to install/run Qt Designer

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

如何启动QtDesigner?

我已经通过 pip 安装了 PyQt5,我相信我已经确定了安装目录

C:\Users\%username%\AppData\Local\Programs\Python\Python36\Lib\site-packages\PyQt5

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

Qt 设计器pip安装一起安装。

您可以从 sourceforge (probably won't be the last pyqt release, and might be buggy on presence of another installation, like yours) or install it with another (unofficial) pypi package - pyqt5-tools (pip install pyqt5-tools) 下载完整下载,然后从 python 目录的以下子路径 运行 设计器 -

...\Python36\Lib\site-packages\pyqt5-tools\designer\designer.exe

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

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

最后,请注意您还会在 sourceforge 上看到一些用于 PyQt5 的 zip 和 tar.gz 文件。但是,这些仅包含 源代码 ,因此除非您打算自己编译 PyQt5,否则对您没有用。需要明确的是:从源代码编译 仍然不会为您提供所有 Qt 开发工具 。如果你沿着这条路走下去,你还需要单独安装整个 Qt 开发工具包( 然后为你提供开发工具)。

您也可以通过以下方式安装Qt Designer:

  1. Qt main site
  2. 安装最新的 Qt(我使用的是 5.8)
  3. 确保包含 "Qt 5.8 MinGW" 组件
  4. Qt Designer 将安装在 C:\Qt.8\mingw53_32\bin\designer.exe
  5. 请注意,可执行文件名为 "designer.exe"

我也为此苦苦挣扎。 pyqt5-tools 方法很麻烦,所以我创建了一个 standalone installer for Qt Designer。它只有 40 MB。也许你会发现它有用!

尝试使用:

pip install pyqt5-tools

现在您可以在 site-packages/pyqt5-tools 中找到设计师。

pip install pyqt5-tools

然后重启cmd,输入"designer"回车即可

pip install pyqt5-tools

工作 python 3.7.4

无法在 python 3.8.0

中工作

使用pip下载模块:

pip install PyQt5Designer

然后,对于 anaconda 用户,打开:

C:\ProgramData\AnacondaX\Lib\site-packages\QtDesigner\designer.exe

python 用户:

  • 64 位:

    C:\Program Files\PythonXX\Lib\site-packages\QtDesigner\designer.exe
    
  • 32 位:

    C:\Program Files (x86)\PythonXX\Lib\site-packages\QtDesigner\designer.exe
    

我遇到了同样的问题,但是我能够使用 Pygame 模块安装代码进行安装,更改一些信息:

pygame:

py -m pip install -U pygame --user

PyQt5:

py -m pip install -U pyqt5-tools --user

如果你正在安装 pyqt5-tools 那么你可以在里面找到 designer.exe 文件:

<python_installation>\Lib\site-packages\Qt

如果您找不到该文件或无法直接打开它,请打开命令提示符并键入:

<python_installation>\Scripts\pyqt5designer.exe

PyQt5 在 pip install PyQt5Designer 后工作

如果你使用 anaconda,你应该在这里找到它

C:\Users\%username%\anaconda3\envs\untitled\Lib\site-packages\qt5_applications\Qt\bin

到目前为止,最简单的方法是使用此安装程序:

https://build-system.fman.io/qt-designer-download

似乎这里的其他答案现在已经过时了,更不用说让刚开始接触这个的人感到困惑了。 Sourceforge 不再有这个包,我按照建议安装了工具,但脚本文件夹中没有任何内容,上面的 pip 命令的 none 也有效。

如果您看不到 Designer ,只需查看此路径“Lib\site-packages\qt5_applications\Qt\bin”以获得 designer.exe 和 运行。

对于在 2021 年以后遇到此 post 并发现答案已过时的任何人:QT Designer 现在位于 qt5-applications 包中,位于 Qt\bin\ 下。在 Windows 这意味着默认路径,对于使用 Python.org 安装程序的 CPython 3.9,是 %APPDATA%\Python\Python39\site-packages\qt5_applications\Qt\bin\designer.exe.

如果您在 python 虚拟环境中工作,请在命令 window

>>qt5-tools designer

可以打开设计器window。

对于 Qt Designer 6 这对我有用感谢@Bhaskar 的提示

pip install pyqt6-tools

然后开始:

qt6-tools designer

最终得到工作良好的轻量级 Qt Designer 6.0.1 版本

@ pip install pyqt6-tools
Collecting pyqt6-tools
  Using cached pyqt6_tools-6.1.0.3.2-py3-none-any.whl (29 kB)
Collecting pyqt6-plugins<6.1.0.3,>=6.1.0.2.2
  Downloading pyqt6_plugins-6.1.0.2.2-cp39-cp39-manylinux2014_x86_64.whl (77 kB)
     |████████████████████████████████| 77 kB 492 kB/s            
Collecting python-dotenv
  Using cached python_dotenv-0.19.2-py2.py3-none-any.whl (17 kB)
Collecting pyqt6==6.1.0
  Downloading PyQt6-6.1.0-cp36.cp37.cp38.cp39-abi3-manylinux_2_28_x86_64.whl (6.8 MB)
     |████████████████████████████████| 6.8 MB 1.0 MB/s            
Requirement already satisfied: click in ./.pyenv/versions/3.9.6/lib/python3.9/site-packages (from pyqt6-tools) (8.0.1)
Collecting PyQt6-sip<14,>=13.1
  Downloading PyQt6_sip-13.2.0-cp39-cp39-manylinux1_x86_64.whl (307 kB)
     |████████████████████████████████| 307 kB 898 kB/s            
Collecting PyQt6-Qt6>=6.1.0
  Using cached PyQt6_Qt6-6.2.2-py3-none-manylinux_2_28_x86_64.whl (50.0 MB)
Collecting qt6-tools<6.1.0.2,>=6.1.0.1.2
  Downloading qt6_tools-6.1.0.1.2-py3-none-any.whl (13 kB)
Collecting click
  Downloading click-7.1.2-py2.py3-none-any.whl (82 kB)
     |████████████████████████████████| 82 kB 381 kB/s            
Collecting qt6-applications<6.1.0.3,>=6.1.0.2.2
  Downloading qt6_applications-6.1.0.2.2-py3-none-manylinux2014_x86_64.whl (80.5 MB)
     |████████████████████████████████| 80.5 MB 245 kB/s            
Installing collected packages: qt6-applications, PyQt6-sip, PyQt6-Qt6, click, qt6-tools, pyqt6, python-dotenv, pyqt6-plugins, pyqt6-tools
  Attempting uninstall: click
    Found existing installation: click 8.0.1
    Uninstalling click-8.0.1:
      Successfully uninstalled click-8.0.1
Successfully installed PyQt6-Qt6-6.2.2 PyQt6-sip-13.2.0 click-7.1.2 pyqt6-6.1.0 pyqt6-plugins-6.1.0.2.2 pyqt6-tools-6.1.0.3.2 python-dotenv-0.19.2 qt6-applications-6.1.0.2.2 qt6-tools-6.1.0.1.2