pip命令安装第三方库报错Failed cleaning build dir for cryptography的解决方案

问题描述

pip命令安装第三方库报错时,提示这样的错误信息:

Failed cleaning build dir for cryptography
Failed to build cryptography
Could not build wheels for cryptography which use PEP 517 and cannot be installed directly

比如,安装selenium失败,如下图:
安装selenium失败示例图

解决方案

根据提示信息,给pip版本进行升级

python -m pip install --upgrade pip

执行成功后,就可以看到,你从什么版本升级到什么版本了

再执行前面失败的安装命令即可(安装完即会提示Successfully在这里插入图片描述

万一哈,如果不成功

可以再尝试执行这两行命令

pip install --only-binary :all: cryptography
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple

走过路过的朋友,如果有实战没解决,或者有其他解决方案的,欢迎在评论区进行讨论