解决Python3.5.4安装PyQt5时出现“Could not build wheels for PyQt5-sip which use PEP 517 and cannot be installed”错误

当尝试安装PyQt5-sip或其他依赖PEP 517构建机制的Python包时,遇到“Could not build wheels”的错误,这通常是由于编译环境不完整或者缺少必要的构建工具链导致的。
首先确保正在使用的pip版本是最新的,因为较老版本的pip可能不完全支持PEP 517。更新pip和setuptools:

python -m pip install --upgrade pip setuptools wheel

更新pip和setuptools完成后再安装pyqt5仍然弹出:
ERROR: Failed building wheel for PyQt5-sip
Failed to build PyQt5-sip ERROR:
Could not build wheels for PyQt5-sip which use PEP 517 and cannot be installed directly

问题出现在编译过程中找不到 “io.h” 头文件,这是C语言编程中用于输入/输出操作的一个标准头文件,在Windows的Visual Studio编译环境下通常是可用的。

解决这个问题需要确保安装了适用于Windows的C/C++构建工具,特别是 “Windows 10 SDK”,它包含了 “io.h” 文件。
于是直接在Visual Studio Installer中添加或更新Windows 10 SDK。
中间VS弹出网络问题无法安装,通过改Hosts的ip解决:
Visual Studio Installer下载,网络连接失败如何解决

完成以上步骤后,重新尝试安装PyQt5-sip:

python -m pip install PyQt5-sip

或者

pip3 install PyQt5==5.13-i https://pypi.tuna.tsinghua.edu.cn/simple python -m pip install PyQt5==5.15.2
物联沃分享整理
物联沃-IOTWORD物联网 » 解决Python3.5.4安装PyQt5时出现“Could not build wheels for PyQt5-sip which use PEP 517 and cannot be installed”错误

发表评论