最近学习Python GUI。想使用pyqt的designer.exe。安装pyqt-tools出现如下错误。

...
Collecting python-dotenv
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/30/5f/2e5c564bd86349fe6b82ca840f46acf6f4bb76d79ba9057fce3d3e008864/python_dotenv-0.20.0-py3-none-any.whl (17 kB)
Collecting click
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/c2/f1/df59e28c642d583f7dacffb1e0965d0e00b218e0186d7858ac5233dce840/click-8.1.3-py3-none-any.whl (96 kB)
     ---------------------------------------- 96.6/96.6 kB 5.4 MB/s eta 0:00:00
Collecting pyqt5==5.15.4
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/8e/a4/d5e4bf99dd50134c88b95e926d7b81aad2473b47fde5e3e4eac2c69a8942/PyQt5-5.15.4.tar.gz (3.3 MB)
     ---------------------------------------- 3.3/3.3 MB 9.9 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
  ╰─> [29 lines of output]
      Traceback (most recent call last):
        File "C:\Program Files\Python310\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:\Program Files\Python310\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 363, in <module>
          main()
        File "C:\Program Files\Python310\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:\Program Files\Python310\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\yanfeng.xia\AppData\Local\Temp\pip-build-env-s4nv4qi0\overlay\Lib\site-packages\sipbuild\api.py", line 46, in build_wheel
          project = AbstractProject.bootstrap('wheel',
        File "C:\Users\yanfeng.xia\AppData\Local\Temp\pip-build-env-s4nv4qi0\overlay\Lib\site-packages\sipbuild\abstract_project.py", line 87, in bootstrap
          project.setup(pyproject, tool, tool_description)
        File "C:\Users\yanfeng.xia\AppData\Local\Temp\pip-build-env-s4nv4qi0\overlay\Lib\site-packages\sipbuild\project.py", line 584, in setup
          self.apply_user_defaults(tool)
        File "C:\Users\yanfeng.xia\AppData\Local\Temp\pip-install-s2bs0m32\pyqt5_0ce192c9eee24750931007c1402fd547\project.py", line 63, in apply_user_defaults
          super().apply_user_defaults(tool)
        File "C:\Users\yanfeng.xia\AppData\Local\Temp\pip-build-env-s4nv4qi0\overlay\Lib\site-packages\pyqtbuild\project.py", line 70, in apply_user_defaults
          super().apply_user_defaults(tool)
        File "C:\Users\yanfeng.xia\AppData\Local\Temp\pip-build-env-s4nv4qi0\overlay\Lib\site-packages\sipbuild\project.py", line 236, in apply_user_defaults
          self.builder.apply_user_defaults(tool)
        File "C:\Users\yanfeng.xia\AppData\Local\Temp\pip-build-env-s4nv4qi0\overlay\Lib\site-packages\pyqtbuild\builder.py", line 67, in apply_user_defaults
          raise PyProjectOptionException('qmake',
      sipbuild.pyproject.PyProjectOptionException
      [end of output]

百度了一下,解决方案如下:

1.下载两个文件:https://github.com/altendky/pyqt-tools/files/8184444/PyQt5-tools-renamed-packages.zip

2.pip安装这两个文件

C:\Users\yanfeng.xia>pip install PyQt5-5.15.4-py3-none-win_amd64.whl
Processing c:\users\yanfeng.xia\pyqt5-5.15.4-py3-none-win_amd64.whl
Requirement already satisfied: PyQt5-sip<13,>=12.8 in c:\program files\python310\lib\site-packages (from PyQt5==5.15.4) (12.11.0)
Requirement already satisfied: PyQt5-Qt5>=5.15 in c:\program files\python310\lib\site-packages (from PyQt5==5.15.4) (5.15.2)
Installing collected packages: PyQt5
  Attempting uninstall: PyQt5
    Found existing installation: PyQt5 5.15.7
    Uninstalling PyQt5-5.15.7:
      Successfully uninstalled PyQt5-5.15.7
Successfully installed PyQt5-5.15.4

C:\Users\yanfeng.xia>pip install pyqt5_plugins-5.15.4.2.2-py3-none-win_amd64.whl
Processing c:\users\yanfeng.xia\pyqt5_plugins-5.15.4.2.2-py3-none-win_amd64.whl
Collecting qt5-tools<5.15.2.2,>=5.15.2.1.2
  Downloading qt5_tools-5.15.2.1.2-py3-none-any.whl (13 kB)
Collecting click
  Using cached click-8.1.3-py3-none-any.whl (96 kB)
Requirement already satisfied: pyqt5==5.15.4 in c:\program files\python310\lib\site-packages (from pyqt5-plugins==5.15.4.2.2) (5.15.4)
Requirement already satisfied: PyQt5-sip<13,>=12.8 in c:\program files\python310\lib\site-packages (from pyqt5==5.15.4->pyqt5-plugins==5.15.4.2.2) (12.11.0)
Requirement already satisfied: PyQt5-Qt5>=5.15 in c:\program files\python310\lib\site-packages (from pyqt5==5.15.4->pyqt5-plugins==5.15.4.2.2) (5.15.2)
Collecting qt5-applications<5.15.2.3,>=5.15.2.2.2
  Downloading qt5_applications-5.15.2.2.2-py3-none-win_amd64.whl (60.9 MB)
     ---------------------------------------- 60.9/60.9 MB 25.2 kB/s eta 0:00:00
Collecting click
  Downloading click-7.1.2-py2.py3-none-any.whl (82 kB)
     ---------------------------------------- 82.8/82.8 kB 20.5 kB/s eta 0:00:00
Installing collected packages: qt5-applications, click, qt5-tools, pyqt5-plugins
Successfully installed click-7.1.2 pyqt5-plugins-5.15.4.2.2 qt5-applications-5.15.2.2.2 qt5-tools-5.15.2.1.2

3.安装pyqt-tools,即可成功

C:\Users\yanfeng.xia>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyqt5-tools
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting pyqt5-tools
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/b7/70/a25aab849a5e38ae78716acde1f917a14d9d819c8600bbb8cf536781f7c5/pyqt5_tools-5.15.4.3.2-py3-none-any.whl (29 kB)
Collecting python-dotenv
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/30/5f/2e5c564bd86349fe6b82ca840f46acf6f4bb76d79ba9057fce3d3e008864/python_dotenv-0.20.0-py3-none-any.whl (17 kB)
Requirement already satisfied: pyqt5==5.15.4 in c:\program files\python310\lib\site-packages (from pyqt5-tools) (5.15.4)
Requirement already satisfied: pyqt5-plugins<5.15.4.3,>=5.15.4.2.2 in c:\program files\python310\lib\site-packages (from pyqt5-tools) (5.15.4.2.2)
Requirement already satisfied: click in c:\program files\python310\lib\site-packages (from pyqt5-tools) (7.1.2)
Requirement already satisfied: PyQt5-Qt5>=5.15 in c:\program files\python310\lib\site-packages (from pyqt5==5.15.4->pyqt5-tools) (5.15.2)
Requirement already satisfied: PyQt5-sip<13,>=12.8 in c:\program files\python310\lib\site-packages (from pyqt5==5.15.4->pyqt5-tools) (12.11.0)
Requirement already satisfied: qt5-tools<5.15.2.2,>=5.15.2.1.2 in c:\program files\python310\lib\site-packages (from pyqt5-plugins<5.15.4.3,>=5.15.4.2.2->pyqt5-tools) (5.15.2.1.2)
Requirement already satisfied: qt5-applications<5.15.2.3,>=5.15.2.2.2 in c:\program files\python310\lib\site-packages (from qt5-tools<5.15.2.2,>=5.15.2.1.2->pyqt5-plugins<5.15.4.3,>=5.15.4.2.2->pyqt5-tools) (5.15.2.2.2)
Installing collected packages: python-dotenv, pyqt5-tools
Successfully installed pyqt5-tools-5.15.4.3.2 python-dotenv-0.20.0

原帖地址:Error while doing 'pip install Pyqt5-tools' · Issue #100 · altendky/pyqt-tools · GitHub

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐