树莓派3B+安装firebase-admin时出现cryptography编译wheel错误
解决树莓派3B+(Raspbian Buster)安装firebase-admin时"Error building wheel for cryptography"的问题
问题核心
从错误日志能看出两个关键矛盾:
- 高版本setuptools(67.0.0)和Python3.7不兼容,触发了
cryptography.hazmat.bindings._rust的包发现警告 - 编译cryptography时找不到Rust编译器,且armv7平台无预编译wheel可用
分步解决方案
1. 降级setuptools到Python3.7兼容版本
新版本setuptools对Python3.7的包处理逻辑有变更,先降级:
pip3 install setuptools==58.0.4
2. 正确安装并激活Rust工具链
之前安装Rust后可能未配置环境变量,重新安装并生效:
# 安装rustup curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh # 激活Rust环境(当前终端生效,永久生效可重启终端或添加到bashrc) source $HOME/.cargo/env # 验证Rust版本(需>=1.48.0) rustc --version
3. 安装系统层面的编译依赖
确保cryptography编译所需的基础库都已安装:
sudo apt-get update && sudo apt-get install -y build-essential libssl-dev libffi-dev python3-dev
4. 安装firebase-admin
可以先单独安装兼容版本的cryptography,再安装firebase-admin:
pip3 install cryptography==38.0.4 pip3 install firebase-admin
或者直接跳过构建隔离,让pip使用当前环境的依赖:
pip3 install firebase-admin --no-build-isolation
为什么之前的尝试无效?
- 重装系统后未指定setuptools版本,pip会自动安装最新版,再次触发版本兼容问题
- Rust安装后未激活环境变量,编译时系统找不到rustc
- 缺少系统级编译依赖,即使有Rust也无法完成cryptography的编译
内容的提问来源于stack exchange,提问作者Omar Khaled
相关产品推荐
相关产品推荐

