【Python】解决pip安装pyqt报错:Building wheel for PyQt5-sip (pyproject.toml) did not run successfully

成功解决python报错:Building wheel for PyQt5-sip (pyproject.toml) did not run successfully。error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools”: https://visualstudio.microsoft.com/visual-cpp-build-tools/

在这里插入图片描述


🧑 博主简介:现任阿里巴巴嵌入式技术专家,15年工作经验,深耕嵌入式+人工智能领域,精通嵌入式领域开发、技术管理、简历招聘面试。CSDN优质创作者,提供产品测评、学习辅导、简历面试辅导、毕设辅导、项目开发、C/C++/Java/Python/Linux/AI等方面的服务,如有需要请站内私信或者联系任意文章底部的的VX名片(ID:gylzbk

💬 博主粉丝群介绍:① 群内高中生、本科生、研究生、博士生遍布,可互相学习,交流困惑。② 热榜top10的常客也在群里,也有数不清的万粉大佬,可以交流写作技巧,上榜经验,涨粉秘籍。③ 群内也有职场精英,大厂大佬,可交流技术、面试、找工作的经验。④ 进群免费赠送写作秘籍一份,助你由写作小白晋升为创作大佬。⑤ 进群赠送CSDN评论防封脚本,送真活跃粉丝,助你提升文章热度。有兴趣的加文末联系方式,备注自己的CSDN昵称,拉你进群,互相学习共同进步。

在这里插入图片描述

在这里插入图片描述

问题背景

Windows平台安装PyQt的过程中,会遇到error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/的报错导致安装失败。本文将带你一步一步通过2种方法解决这个问题。

问题现象

使用pip来安装PyQt5和相关工具包:

pip install PyQt5 PyQt5-tools

安装过程中有如下错误:

Using cached colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Using cached importlib_metadata-6.7.0-py3-none-any.whl (22 kB)
Using cached qt5_applications-5.15.2.2.3-py3-none-win_amd64.whl (64.5 MB)
Using cached typing_extensions-4.7.1-py3-none-any.whl (33 kB)
Using cached zipp-3.15.0-py3-none-any.whl (6.8 kB)
Building wheels for collected packages: PyQt5-sip
  Building wheel for PyQt5-sip (pyproject.toml): started
  Building wheel for PyQt5-sip (pyproject.toml): finished with status 'error'
  error: subprocess-exited-with-error

  Building wheel for PyQt5-sip (pyproject.toml) did not run successfully.
  exit code: 1

  [5 lines of output]
  running bdist_wheel
  running build
  running build_ext
  building 'PyQt5.sip' extension
  error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
  [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for PyQt5-sip
Failed to build PyQt5-sip
ERROR: Could not build wheels for PyQt5-sip, which is required to install pyproject.toml-based projects

在这里插入图片描述

解决方案1:安装Microsoft C++ Build Tools

Windows平台安装过程中遇到这个错误,说明需要用到Microsoft C++ Build Tools。大概步骤如下:

1. 下载Microsoft C++ Build Tools

  1. 访问微软开发工具官方下载网站:https://visualstudio.microsoft.com/visual-cpp-build-tools/
    在这里插入图片描述
  2. 点击下载生成工具按钮,下载安装包。安装包只是个壳,很快就可以下载完成。

2. 安装Microsoft C++ Build Tools

运行安装包,如下图所示,点击继续按钮,进入安装界面之后,选择使用C++的桌面开发,然后点击右下角的安装,直至安装完成即可。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

3. 重新安装PyQt

重新执行pyqt安装命令,即可安装成功。

pip install PyQt5 PyQt5-tools

解决方案2:手动下载安装whl文件

下载安装Microsoft C++ Build Tools,需要很长的时间,另外需要下载大量的文件,耗时费力。如果你不想那么费事,还可以手动下载whl文件,手动安装,以跳过这个错误。
方法如下:

1. 下载whl文件

whl下载地址:https://pypi.tuna.tsinghua.edu.cn/simple/pyqt5-sip/。比如我是Win10 64位(对应win_amd64)系统,python版本为3.7.0(对应cp37),所以我选择了适配与我的系统和python版本的PyQt5_sip最新版本whl文件:PyQt5_sip-12.12.2-cp37-cp37m-win_amd64.whl

2. 安装whl

whl文件下载后使用pip install PyQt5_sip-12.12.2-cp37-cp37m-win_amd64.whl命令安装它。
在这里插入图片描述

3. 重新安装PyQt

最后,重新执行pyqt安装命令,如下图所示,即可安装成功。

pip install PyQt5 PyQt5-tools

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

I'mAlex

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值