You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Google App Engine Flexible中使用pandas 1.3.4及更高版本

问题背景

我使用搭载标准Python 3运行时的Google App Engine Flexible环境,此前一直使用pandas 1.0.5版本,现在计划升级使用pandas 1.3.4。更新requirements.txt文件后尝试部署到GAE,返回如下报错:

Step #1: ERROR: Could not find a version that satisfies the requirement pandas==1.3.4 (from -r requirements.txt (line 16)) (from versions: 0.1, 0.2, 0.3.0, 0.4.0, 0.4.1, 0.4.2, 0.4.3, 0.5.0, 0.6.0, 0.6.1, 0.7.0, 0.7.1, 0.7.2, 0.7.3, 0.8.0, 0.8.1, 0.9.0, 0.9.1, 0.10.0, 0.10.1, 0.11.0, 0.12.0, 0.13.0, 0.13.1, 0.14.0, 0.14.1, 0.15.0, 0.15.1, 0.15.2, 0.16.0, 0.16.1, 0.16.2, 0.17.0, 0.17.1, 0.18.0, 0.18.1, 0.19.0, 0.19.1, 0.19.2, 0.20.0, 0.20.1, 0.20.2, 0.20.3, 0.21.0, 0.21.1, 0.22.0, 0.23.0, 0.23.1, 0.23.2, 0.23.3, 0.23.4, 0.24.0, 0.24.1, 0.24.2, 0.25.0, 0.25.1, 0.25.2, 0.25.3, 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.1.5)
Step #1: ERROR: No matching distribution found for pandas==1.3.4 (from -r requirements.txt (line 16))
Step #1: WARNING: You are using pip version 20.2.2; however, version 21.3.1 is available.
Step #1: You should consider upgrading via the '/env/bin/python -m pip install --upgrade pip' command.
Step #1: The command '/bin/sh -c pip install -r requirements.txt' returned a non-zero code: 1
Finished Step #1
ERROR

报错中列出的最新pandas版本仅为1.1.5,但pandas官方已正式发布1.3.4版本,现有三个相关问题需要解答:

  • GCloud标准运行时支持的软件包版本更新频率为多少?
  • 软件包的版本可用情况是否与自定义运行时内置的pip版本相关?
  • 无需构建自定义运行时的前提下,是否有方法可以使用最新版本的软件包?

解答

1. GCloud标准运行时软件包版本更新频率

Google Cloud没有公开固定的预构建运行时依赖包版本更新周期,通常会在Python小版本迭代、运行时安全补丁更新、核心依赖兼容性验证完成后同步更新可用包版本池,常规更新周期为1~3个月,存在安全风险的旧版本会被提前从可用列表中移除。

2. 软件包版本可用情况与pip版本的关系

二者直接相关。本次pandas 1.3.4无法找到的核心原因就是当前运行时内置的pip 20.2.2版本过低,pandas 1.2及以上版本使用了新版pip才支持的包元数据格式,旧版pip无法识别匹配对应安装包,拉取版本列表时会自动过滤这类不兼容的高版本包。

3. 无需自定义运行时使用最新软件包的方法

存在可行方案:

  • 首先在requirements.txt的最开头添加pip>=21.3声明
  • 之后在app.yaml的runtime_config配置项下添加pip_upgrade: true字段

部署时运行时会先升级pip到指定的兼容版本,再安装剩余依赖,即可识别并拉取最新版的pandas包。如果当前使用的运行时版本不支持pip_upgrade参数,也可以在项目根目录下新建.gcloudignore规则不排除的前置启动脚本,在应用启动前先执行pip升级操作。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.25 19:54:03