部署Firebase Python函数时遇'determining Python exec prefix: []'错误求助
Firebase Functions部署Python函数报错:determining Python exec prefix: []
问题描述
我使用Python 3.12.3,通过firebase deploy --only functions命令部署Firebase Functions,最简可复现代码如下:
from firebase_functions import https_fn @https_fn.on_request() def hello_world(req: https_fn.Request) -> https_fn.Response: return https_fn.Response("Hello, World!")
但每次都出现构建失败错误:
Build failed with status: FAILURE and message: failed to build: determining Python exec prefix: []
已多次删除venv目录重试,问题仍未解决,且日志无更多相关信息。
解决方法
- 确认Python版本兼容性:Firebase Functions官方目前仅支持Python 3.8、3.9、3.10、3.11,Python 3.12不在支持范围内,这是导致报错的主要原因。
- 降级Python版本到官方支持的版本(比如3.11.x),重新配置环境:
- 安装Python 3.11.x版本(卸载或停用Python 3.12)
- 删除现有venv目录,执行
python -m venv venv创建新虚拟环境 - 激活虚拟环境后,重新安装依赖:
pip install firebase-functions firebase-admin
- 检查
firebase.json配置,确保functions的目录路径正确 - 部署前执行
firebase functions:log,尝试获取更详细的构建日志排查隐藏问题
内容的提问来源于stack exchange,提问作者Raul Ponzheimer
相关产品推荐
相关产品推荐

