我尝试安装 PyQt5 和 PyQt6。在这两种情况下,PyQt 本身都正常安装,但 PyQt-Tools(5 或 6)给出错误“元数据生成失败”。我的Python版本是3.12.3,我使用的是pip 24.0。
错误:
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [26 lines of output]
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 "C:\Users\Artem\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
main()
File "C:\Users\Artem\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Artem\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 152, in prepare_metadata_for_build_wheel
whl_basename = backend.build_wheel(metadata_directory, config_settings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Artem\AppData\Local\Temp\pip-build-env-n4nrn3uv\overlay\Lib\site-packages\sipbuild\api.py", line 46, in build_wheel
project = AbstractProject.bootstrap('wheel',
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Artem\AppData\Local\Temp\pip-build-env-n4nrn3uv\overlay\Lib\site-packages\sipbuild\abstract_project.py", line 92, in bootstrap
project.setup(pyproject, tool, tool_description)
File "C:\Users\Artem\AppData\Local\Temp\pip-build-env-n4nrn3uv\overlay\Lib\site-packages\sipbuild\project.py", line 587, in setup
self.apply_user_defaults(tool)
File "C:\Users\Artem\AppData\Local\Temp\pip-install-9w45o5_u\pyqt6_13c3263a185a4827a4df706f02c146f6\project.py", line 60, in apply_user_defaults
super().apply_user_defaults(tool)
File "C:\Users\Artem\AppData\Local\Temp\pip-build-env-n4nrn3uv\overlay\Lib\site-packages\pyqtbuild\project.py", line 51, in apply_user_defaults
super().apply_user_defaults(tool)
File "C:\Users\Artem\AppData\Local\Temp\pip-build-env-n4nrn3uv\overlay\Lib\site-packages\sipbuild\project.py", line 237, in apply_user_defaults
self.builder.apply_user_defaults(tool)
File "C:\Users\Artem\AppData\Local\Temp\pip-build-env-n4nrn3uv\overlay\Lib\site-packages\pyqtbuild\builder.py", line 50, in apply_user_defaults
raise PyProjectOptionException('qmake',
sipbuild.pyproject.PyProjectOptionException
[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.
我在网上才发现我需要最新版本的Python(我已经有了),并且PyQt5与Mac上的M1不兼容(我已经尝试安装第五和第六版本,此外,我有一台装有 Windows 和 Intel 的笔记本电脑)。
您可能需要降级您的Python,因为pyqt5-tools和pyqt6-tools都支持Python 3.5 - 3.9。
此外,建议使用 virtualenv 或 venv 创建隔离环境来安装依赖项。