无法在 Windows 上的 Python 3.11 中安装 PyQt6 工具

2023-12-24

我安装了Python 3.11在我的 Windows 11 计算机上预发布:https://www.python.org/downloads/release/python-3110a7/ https://www.python.org/downloads/release/python-3110a7/

我安装在文件夹里C:\Python311\

然后我启动了命令提示符并安装wheel, pyqt6 and pyqt6-tools。正如你所看到的,安装时出现了问题pyqt6-tools:

>pip install wheel
Collecting wheel
  Downloading wheel-0.37.1-py2.py3-none-any.whl (35 kB)
Installing collected packages: wheel
Successfully installed wheel-0.37.1
>pip install pyqt6
Collecting pyqt6
  Downloading PyQt6-6.3.0-cp37-abi3-win_amd64.whl (6.2 MB)
     ---------------------------------------- 6.2/6.2 MB 10.7 MB/s eta 0:00:00
Collecting PyQt6-sip<14,>=13.2
  Downloading PyQt6_sip-13.3.1.tar.gz (108 kB)
     ---------------------------------------- 108.3/108.3 KB 6.1 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting PyQt6-Qt6>=6.3.0
  Downloading PyQt6_Qt6-6.3.0-py3-none-win_amd64.whl (45.8 MB)
     ---------------------------------------- 45.8/45.8 MB 11.3 MB/s eta 0:00:00
Building wheels for collected packages: PyQt6-sip
  Building wheel for PyQt6-sip (pyproject.toml) ... done
  Created wheel for PyQt6-sip: filename=PyQt6_sip-13.3.1-cp311-cp311-win_amd64.whl size=71550 sha256=4bc5340bdce65cccb581389f646d712aa78abbdae84d461120e9565426dc93c8
  Stored in directory: C:\Users\krist\AppData\Local\Temp\pip-ephem-wheel-cache-jmbk1_kb\wheels\c3\af\39\f00fa6b0b54378c6b571e7d38750537a92e95390d4247d3b9e
Successfully built PyQt6-sip
Installing collected packages: PyQt6-Qt6, PyQt6-sip, pyqt6
Successfully installed PyQt6-Qt6-6.3.0 PyQt6-sip-13.3.1 pyqt6-6.3.0
>pip install pyqt6-tools
Collecting pyqt6-tools
  Downloading pyqt6_tools-6.1.0.3.2-py3-none-any.whl (29 kB)
  Downloading pyqt6_tools-6.0.3.3.2-py3-none-any.whl (29 kB)
Collecting click
  Downloading click-8.1.3-py3-none-any.whl (96 kB)
     ---------------------------------------- 96.6/96.6 KB 5.4 MB/s eta 0:00:00
Collecting pyqt6-tools
  Downloading pyqt6_tools-6.0.2.3.2-py3-none-any.whl (29 kB)
Collecting pyqt6==6.0.2
  Downloading PyQt6-6.0.2.tar.gz (940 kB)
     ---------------------------------------- 940.8/940.8 KB 6.6 MB/s eta 0:00:00
  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
  ╰─> [40 lines of output]
      Traceback (most recent call last):
        File "C:\Python311\Lib\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 "C:\Python311\Lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 363, in <module>
          main()
          ^^^^^^
        File "C:\Python311\Lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Python311\Lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 160, in prepare_metadata_for_build_wheel
          whl_basename = backend.build_wheel(metadata_directory, config_settings)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\krist\AppData\Local\Temp\pip-build-env-1ejos5sl\overlay\Lib\site-packages\sipbuild\api.py", line 51, in build_wheel
          project = AbstractProject.bootstrap('pep517')
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\krist\AppData\Local\Temp\pip-build-env-1ejos5sl\overlay\Lib\site-packages\sipbuild\abstract_project.py", line 83, in bootstrap
          project.setup(pyproject, tool, tool_description)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\krist\AppData\Local\Temp\pip-build-env-1ejos5sl\overlay\Lib\site-packages\sipbuild\project.py", line 594, in setup
          self.apply_user_defaults(tool)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\krist\AppData\Local\Temp\pip-install-tat_ias8\pyqt6_920842ce0fe64e4a89597e45e5a8549f\project.py", line 60, in apply_user_defaults
          super().apply_user_defaults(tool)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\krist\AppData\Local\Temp\pip-build-env-1ejos5sl\overlay\Lib\site-packages\pyqtbuild\project.py", line 70, in apply_user_defaults
          super().apply_user_defaults(tool)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\krist\AppData\Local\Temp\pip-build-env-1ejos5sl\overlay\Lib\site-packages\sipbuild\project.py", line 241, in apply_user_defaults
          self.builder.apply_user_defaults(tool)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\krist\AppData\Local\Temp\pip-build-env-1ejos5sl\overlay\Lib\site-packages\pyqtbuild\builder.py", line 67, 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.

我认为原因可能与访问权限有关。所以我在管理模式下启动了cmd提示符。不幸的是,问题依然存在。


这是在 Python 3.11 上安装 pyqt6 的完整指南

  1. 从 pypi 下载文件。这是链接:https://pypi.org/project/PyQt6/#files https://pypi.org/project/PyQt6/#files。下载名为“PyQt6-6.4.1-cp37-abi3-win_amd64.whl”的 Windows 版本
  2. 将文件重命名为“PyQt6-6.4.1-py3-none-win_amd64.whl”
  3. 现在也从 pypi 下载插件文件。这是链接:https://pypi.org/project/pyqt6-plugins/#files https://pypi.org/project/pyqt6-plugins/#files。下载名为“pyqt6_plugins-6.1.0.2.2-cp39-cp39-win_amd64.whl”的文件
  4. 将最后一个文件重命名为“pyqt6_plugins-6.1.0.2.2-py3-none-win_amd64.whl”
  5. 现在,使用 WinRar (或类似的)打开最后一个文件,该文件现在被重命名为“pyqt6_plugins-6.1.0.2.2-py3-none-win_amd64.whl”
  6. 打开文件夹“pyqt6_plugins-6.1.0.2.2.dist-info”
  7. 使用文本编辑器打开文件“METADATA”
  8. 找到行:“Requires-Dist: pyqt6 (==6.1.0)”并更改为“Requires-Dist: pyqt6”。保存文件。
  9. 现在你的 2 个文件已经准备好了,你只需要手动 pip install 这些文件:

pip 安装 PyQt6-6.4.1-py3-none-win_amd64.whl

pip 安装 pyqt6_plugins-6.1.0.2.2-py3-none-win_amd64.whl

  1. 完毕!你已经在Python 3.11中安装了Pyqt6!

所有功劳归用户所有https://github.com/liudonghua123 https://github.com/liudonghua123这解决了 pyqt5 中的这个问题https://github.com/altendky/pyqt-tools/issues/108 https://github.com/altendky/pyqt-tools/issues/108,这只是相同的解决方案,但应用于 pyqt6。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

无法在 Windows 上的 Python 3.11 中安装 PyQt6 工具 的相关文章

随机推荐