Sunday, April 08, 2018

Deploying Python app to Google Cloud Platform (GCP) fails for numpy==1.9.3

I'm not sure what caused this issue. I've had this GCP Python app running for many months, but today the deploy command failed with this error.


$ gcloud app deploy ~/appFolder/app.yaml ~/appFolder/cron.yaml --verbosity=error

Step #1:   Could not find a version that satisfies the requirement numpy==1.9.3 (from versions: 1.14.5, 1.14.6, 1.15.0rc2, 1.15.0, 1.15.1, 1.15.2, 1.15.3, 1.15.4, 1.16.0rc1, 1.16.0rc2, 1.16.0, 1.16.1)
Step #1: No matching distribution found for numpy==1.9.3
Step #1: You are using pip version 10.0.1, however version 19.0.1 is available.
Step #1: You should consider upgrading via the '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
ERROR: build step 1 "gcr.io/cloud-builders/docker@sha256:1f0bba269252a1b2cde650368ddc970afe80207986a88b8a0011e94b8xxxxxx" failed: exit status 1
Step #1: 
-------------------------------------------------------------------------------------------------------------


ERROR: (gcloud.app.deploy) Cloud build failed. 

To resolve the issue, I changed this line in requirements.txt from:

pandas==0.22.0

to:

pandas; python_version >= '3.5'
pandas<0.21; python_version == '3.4'

Then I ran:


$ pip install  -r requirements.txt

I found this solution in a comment on this GitHub issue: https://github.com/pandas-dev/pandas/issues/20697