Google-cloud-python: Storage: cannot import name AnonymousCredentials

Created on 14 Mar 2018  路  3Comments  路  Source: googleapis/google-cloud-python

Deploying an app we've been running for about a year now, and we noticed the API has changed, and we're seeing the error below at startup. The environment is Cloud Foundry, running on GCP. Here are the details:

  • OS: Ubuntu 14.04.5 LTS
  • Python 2.7.6
  • requirements.txt is as follows:
Flask
gunicorn
scipy
h5py
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.0.0-cp27-none-linux_x86_64.whl
keras
Pillow
google-cloud
google-cloud-language
google-cloud-vision
google-cloud-storage
git+https://github.com/pivotal-partner-solution-architecture/pcf-gcp-python.git#egg=pcfgcp

Here is the stack trace (this is from an app deployed to Cloud Foundry):

2018-03-14T13:30:11.29-0600 [APP/PROC/WEB/0] ERR Traceback (most recent call last):
  2018-03-14T13:30:11.29-0600 [APP/PROC/WEB/0] ERR   File "image_matcher.py", line 41, in <module>
  2018-03-14T13:30:11.29-0600 [APP/PROC/WEB/0] ERR     from google.cloud import storage
  2018-03-14T13:30:11.29-0600 [APP/PROC/WEB/0] ERR   File "/app/.cloudfoundry/python/lib/python2.7/site-packages/google/cloud/storage/__init__.py", line 40, in <module>
  2018-03-14T13:30:11.29-0600 [APP/PROC/WEB/0] ERR     from google.cloud.storage.client import Client
  2018-03-14T13:30:11.29-0600 [APP/PROC/WEB/0] ERR   File "/app/.cloudfoundry/python/lib/python2.7/site-packages/google/cloud/storage/client.py", line 18, in <module>
  2018-03-14T13:30:11.29-0600 [APP/PROC/WEB/0] ERR     from google.auth.credentials import AnonymousCredentials
  2018-03-14T13:30:11.29-0600 [APP/PROC/WEB/0] ERR ImportError: cannot import name AnonymousCredentials
  2018-03-14T13:30:11.37-0600 [APP/PROC/WEB/0] OUT Exit status 1
question storage packaging

Most helpful comment

You are running with a too-old version of google-auth for the version you have of google-cloud-storage: it needs at least version 1.2.0 of google-auth.

All 3 comments

You are running with a too-old version of google-auth for the version you have of google-cloud-storage: it needs at least version 1.2.0 of google-auth.

Many thanks, @tseaver

@tseaver curious why google-cloud-storage don't define min version of google-auth but you let the users install google-cloud-storage with a wrong version of google-auth. I understand that it is easier for you to don't follow dependency between packages version, and let the users discover with exceptions dependency for you.

You have a partial dependency version explicitly defined but google-auth it is missing: https://github.com/googleapis/google-cloud-python/blob/master/storage/setup.py#L31

IMHO a good package should list all needed packages and associated version to make it work without exception of missing import.

Was this page helpful?
0 / 5 - 0 ratings