pyqt-tools出现如下错误

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

 
  1. ...
    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安装这两个文件,顺序不能乱

D:\python charm\PyCharm Community Edition 2021.2.3\external>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
 
D:\python charm\PyCharm Community Edition 2021.2.3\external>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,即可成功

D:\python charm\PyCharm Community Edition 2021.2.3\external>pip install 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

### 解决 `pip` 安装 `pyqt5-tools` 时出现的 'No matching distribution found' 错误 当尝试通过 `pip install pyqt5-tools` 命令安装 `pyqt5-tools` 时,如果遇到 `Could not find a version that satisfies the requirement pyqt5-tools` 或者 `No matching distribution found for pyqt5-tools` 的错误提示,可以考虑以下几个解决方案。 #### 使用国内镜像源加速安装过程 为了提高下载速度并减少因网络问题导致的安装失败情况,建议使用国内的 PyPI 镜像站点来执行安装操作。例如阿里云提供的 Python 包托管服务: ```bash pip install pyqt5-tools -i https://mirrors.aliyun.com/pypi/simple/ ``` 这条命令指定了一个更稳定的索引 URL 来查找所需的软件包及其依赖项[^2]。 #### 更新或降级 `pip` 版本 有时过旧或最新的 `pip` 可能会存在兼容性问题,影响到特定库的成功安装。因此更新至最新稳定版或是回退到之前版本可能有助于解决问题: ```bash python -m pip install --upgrade pip # 或者指定某个具体的历史版本号进行安装 python -m pip install pip==21.3.1 ``` 完成上述更改后再试一次原生的 `pip install pyqt5-tools` 操作看是否有所改善。 #### 手动下载并安装离线包 对于那些持续无法在线获取合适二进制文件的情况,可以从第三方资源网站找到适用于 Windows 平台预编译好的 `.whl` 文件手动下载下来再利用本地路径来进行安装。注意要选择与当前使用的 Python 解释器相匹配架构(如 x86/x64)以及对应的 Python 版本的轮子文件。之后可以通过如下方式完成安装: ```bash pip install path_to_downloaded_wheel_file.whl ``` 这里提到的一个例子是从 GitCode 上面共享出来的针对此问题定制化的打包方案[^4]。 #### 考虑替代品或其他发行渠道 如果经过多次努力仍然未能成功部署,则不妨思考是否有其他官方推荐的方式可以获得相同的功能集。比如直接从 Anaconda 发行版中引入环境变量支持 Qt 应用程序开发;或者是探索社区维护的不同分支里有没有更加健壮的选择。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值