我尝试用 pip 安装 pytq5 并得到这个错误
$ python3 -m pip install PyQt5
Collecting PyQt5
Using cached PyQt5-5.15.6.tar.gz (3.2 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [29 lines of output]
Traceback (most recent call last):
File "/Users/olivierskonieczny/Desktop/app/python/ObjectDetection/envs/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 156, in prepare_metadata_for_build_wheel
hook = backend.prepare_metadata_for_build_wheel
AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/olivierskonieczny/Desktop/app/python/ObjectDetection/envs/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
main()
...
...
...
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
我仍然可以安装 lxml 等其他软件包,但无法安装 pytq5。我正在虚拟环境中安装所有内容。
有任何想法吗 ??
原文由 sconiac 发布,翻译遵循 CC BY-SA 4.0 许可协议
特定于 MacOS 的答案
您需要在系统中安装 Qt5,并且需要在
qmake
中安装它的 ---PATH
。要安装 Qt5,您可以运行
brew install qt5
或从 https://www.qt.io/download-qt-installer 下载安装程序。请注意,如果您选择使用安装程序,则需要您登录或创建一个 qt.io 帐户才能执行安装。
如果您使用的是旧版 MacOS,则可以从 https://download.qt.io/archive/qt/ 下载旧版安装程序。您可以在 https://doc.qt.io/archives/qt-5.14/supported-platforms.html 中查看哪个版本支持您的操作系统版本,您可以在其中将 url 中的 qt-5.14 替换为您感兴趣的任何版本.
安装后,找到
qmake
所在的位置。对于我使用 5.14.2 的安装程序,它位于/Users/Admin/Qt5.14.2/5.14.2/clang_64/bin
中。您需要将其添加到PATH
环境变量。为此,在您的主文件夹中编辑.bash_profile
(可能需要先按Command + Shift + .
才能在 Finder 中查看点文件)并向其中添加以下内容:现在,启动新终端后,您应该能够输入
qmake
并查看输出的帮助文本。现在应该可以成功安装 PyQt5(前提是您安装的 Qt5 版本支持您的 MacOS 版本)。