You need to enable JavaScript to run this app. 安装django-allauth时cryptography报PEP 517 wheel构建失败如何解决
优惠活动
大模型
产品
解决方案
定价
更多

安装django-allauth时cryptography报PEP 517 wheel构建失败如何解决

Windows Python虚拟环境安装django-allauth时cryptography编译报错解决方案

核心报错原因:安装依赖时cryptography包需要Rust编译环境构建PEP 517规范的wheel包,本地缺少对应环境或配置不生效导致安装失败。
注:你之前设置CRYPTOGRAPHY_DONT_BUILD_RUST=1无效,是因为cryptography 3.4.8之后的版本已经移除了该环境变量的支持,无法通过该参数跳过Rust编译。

方案1:安装预编译版本cryptography(优先推荐,无需配置编译环境)

  • 先升级setuptools和wheel到最新版本:
    pip install --upgrade setuptools wheel pip
  • 直接安装官方预编译的cryptography包,跳过本地编译步骤:
    pip install --only-binary :all: cryptography
  • 完成后重新安装django-allauth:
    pip install django-allauth

方案2:降级cryptography到无Rust依赖版本

如果方案1存在依赖冲突,可安装最后一个不需要Rust编译的cryptography版本:

  • 执行命令安装指定版本:
    pip install cryptography==3.4.8
  • 再执行django-allauth安装命令即可:
    pip install django-allauth

方案3:配置完整Rust编译环境(适合需要使用最新版cryptography的场景)

之前安装Rust后仍报错大概率是环境变量未生效,按以下步骤操作:

  • 完成Rust工具链安装后,完全关闭当前终端/虚拟环境窗口后重新打开,执行rustc --version确认返回版本≥1.41.0,证明环境变量已生效
  • 再次执行安装命令即可:
    pip install django-allauth

内容的提问来源于stack exchange,提问作者Bikramjit Das

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.19 03:54:01