1. 问题
问题:
执行uv add pyqt5时安装失败:
Resolved 144 packages in 6.34s
error: Distribution `pyqt5-qt5==5.15.18 @ registry+https://pypi.org/simple` can't be installed because it doesn't have a source distribution or wheel for the current platform
hint: You're on Windows (`win_amd64`), but `pyqt5-qt5` (v5.15.18) only has wheels for the following platforms: `manylinux2014_x86_64`, `macosx_10_13_x86_64`, `macosx_11_0_arm64`; consider adding your platform to `tool.uv.required-environments` to ensure uv resolves to a version with compatible wheels
如果在pyproject.toml中直接写入pyqt5的话,执行uv sync时会这么报错:
Resolved 145 packages in 1.78s
× Failed to build `pyqt5==5.15.2`
├─▶ The build backend returned an error
╰─▶ Call to `sipbuild.api.build_wheel` failed (exit code: 1)
[stderr]
pyproject.toml: line 7: using '[tool.sip.metadata]' to specify the project
metadata is deprecated and will be removed in SIP v7.0.0, use '[project]'
instead
Traceback (most recent call last):
File "<string>", line 11, in <module>
wheel_filename =
backend.build_wheel("D:\\all_applications\\foruv\\foruvcache\\builds-v0\\.tmpdm8CqW",
{}, None)
File
"D:\all_applications\foruv\foruvcache\builds-v0\.tmpywcL19\Lib\site-packages\sipbuild\api.py",
line 28, in build_wheel
project = AbstractProject.bootstrap('wheel',
arguments=_convert_config_settings(config_settings))
File
"D:\all_applications\foruv\foruvcache\builds-v0\.tmpywcL19\Lib\site-packages\sipbuild\abstract_project.py",
line 74, in bootstrap
project.setup(pyproject, tool, tool_description)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File
"D:\all_applications\foruv\foruvcache\builds-v0\.tmpywcL19\Lib\site-packages\sipbuild\project.py",
line 661, in setup
self.apply_user_defaults(tool)
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File
"D:\all_applications\foruv\foruvcache\sdists-v9\pypi\pyqt5\5.15.2\DCnXDNUwgyaPDx3Z6cidl\src\project.py",
line 63, in apply_user_defaults
super().apply_user_defaults(tool)
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File
"D:\all_applications\foruv\foruvcache\builds-v0\.tmpywcL19\Lib\site-packages\pyqtbuild\project.py",
line 51, in apply_user_defaults
super().apply_user_defaults(tool)
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File
"D:\all_applications\foruv\foruvcache\builds-v0\.tmpywcL19\Lib\site-packages\sipbuild\project.py",
line 248, in apply_user_defaults
self.builder.apply_user_defaults(tool)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File
"D:\all_applications\foruv\foruvcache\builds-v0\.tmpywcL19\Lib\site-packages\pyqtbuild\builder.py",
line 49, in apply_user_defaults
raise PyProjectOptionException('qmake',
"specify a working qmake or add it to PATH")
sipbuild.pyproject.PyProjectOptionException
hint: This usually indicates a problem with the package or the build
environment.
help: `pyqt5` (v5.15.2) was included because `paid-column1` (v0.1.0) depends
on `pyqt5`
2. 原因
原因出在pyqt5官方,他家就限制了最新版pyqt5依赖的pyqt5-qt5包不能在Windows平台上装。
3. 解决方案
我最终成功的解决方案是先uv sync再uv pip install pyqt5。注意如果反过来会把环境改回pyproject.toml的环境,但我觉得uv速度这么快你每次都来一遍也没有关系:
Using Python 3.13.7 environment at: D:\Codes\uv_environment\example\.venv
Resolved 3 packages in 12.74s
Prepared 2 packages in 49.63s
Installed 3 packages in 296ms
+ pyqt5==5.15.11
+ pyqt5-qt5==5.15.2
+ pyqt5-sip==12.17.2
其他提到的可能有用的解决方案:
uv add pyqt5==5.15.11 pyqt5-qt5==5.15.21- 在pyproject.toml中增加(跟上面一条其实是一样的,只是写法不同)2:
或3[dependency-groups] dev = [ "pyqt5==5.15.11", "pyqt5-qt5==5.15.2", ]deps = [ "pyqt5>=5.15.11; sys_platform != 'win32'", "pyqt5<=5.15.2; sys_platform == 'win32'" ] - 在pyproject.toml中增加3:
[tool.uv] constraint-dependencies = ["pyqt5-qt5 <=5.15.2"] - 用PyQt6(草)4
960

被折叠的 条评论
为什么被折叠?



