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
时间: 2025-06-03 11:15:14 浏览: 33
### 解决方案概述
当遇到 `Building wheel for PyQt5-sip` 错误并提示缺少 Microsoft Visual C++ 14.0 或更高版本时,可以通过以下几种方法解决问题。
---
#### 方法一:安装 Microsoft C++ Build Tools
如果系统未安装必要的编译工具链,则需要先安装 **Microsoft C++ Build Tools**:
访问官方网站下载页面:
[https://visualstudio.microsoft.com/visual-cpp-build-tools/](https://visualstudio.microsoft.com/visual-cpp-build-tools/) [^2]。
在安装过程中选择工作负载中的 **C++ build tools** 并确保勾选了 MSVC v142 - VS 2019 C++ x64/x86 build tools(或其他最新版本)。安装完成后,重启计算机以应用更改。随后再次尝试安装依赖项:
```bash
pip install PyQt5-sip
```
此操作提供了构建所需扩展模块的环境支持[^3]。
---
#### 方法二:使用预编译的 Wheel 文件
为了避免手动配置复杂的开发环境,可以直接获取已编译好的 `.whl` 文件进行安装。
前往 PyPI 镜像站点或官方仓库查找适合当前系统的 `PyQt5-sip.whl` 文件。推荐清华大学镜像源地址:
[https://pypi.tuna.tsinghua.edu.cn/simple/pyqt5-sip/](https://pypi.tuna.tsinghua.edu.cn/simple/pyqt5-sip/) [^4]。
找到对应 Python 版本和操作系统架构的 `.whl` 文件后保存至本地磁盘。利用以下命令执行离线安装过程:
```bash
pip install 路径\to\pyqt5_sip‑x.x.x‑cpXX‑win_amd64.whl
```
替换其中的具体文件名部分以便适配实际使用的环境设置。
这种方法绕过了本地编译环节从而规避了潜在的技术障碍[^5]。
---
#### 方法三:降级到兼容版本
有时高版本可能会引入更多的复杂需求而导致冲突发生,因此可以考虑回退到更早且稳定的发布版本来简化问题情境。
通过明确指定特定的历史发行编号来进行约束控制,例如如下写法所示:
```bash
pip install PyQt5==5.15.2 --index-url=https://pypi.tuna.tsinghua.edu.cn/simple/
```
这里选择了相对成熟的 `5.15.2` 发布版本作为示范案例[^6]。
这样做能够减少不必要的麻烦同时保持功能完整性不受影响。
---
### 总结说明
综上所述,针对缺失 Microsoft Visual C++ 编译器所引起的错误现象提出了三种可行解决方案——分别是补充完整的开发套件、采用预先打包完毕的产品形式以及适当降低技术标准要求程度。每一种策略都有其适用范围与优劣之处,可以根据实际情况灵活选取最合适的手段加以实施。
---
阅读全文
相关推荐















