cocomangolicious
cocomangolicious

Reputation: 21

ImportError: No module named auth.credentials

I was trying to add GAE StackDriver logging capability per: https://cloud.google.com/logging/docs/reference/libraries#client-libraries-resources-python

... to a simple web service that I have running, and am getting the following error:

ERROR     2017-02-01 02:46:05,320 - root - Traceback (most recent call last):
  File "/home/ubuntu/workspace/.../bootstrap.py", line 11, in <module>
    from app import create_app
  File "/home/ubuntu/workspace/.../app/__init__.py", line 31, in <module>
    from handlers.hdl_logger import blpLog
  File "/home/ubuntu/workspace/.../app/handlers/hdl_logger.py", line 15, in <module>
    from google.cloud import logging
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/logging/__init__.py", line 18, in <module>
    from google.cloud.logging.client import Client
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/logging/client.py", line 32, in <module>
    from google.cloud.client import JSONClient
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/client.py", line 17, in <module>
    import google.auth.credentials
ImportError: No module named auth.credentials

I have all of this running within a virtual environment. I have looked closely at dependencies, permissions, and checked the dist-packages/google/ dir to confirm that the auth package is in there.

Any help troubleshooting is greatly appreciated.

Upvotes: 1

Views: 5098

Answers (2)

cocomangolicious
cocomangolicious

Reputation: 21

Thanks for the responses.

I was able to solve the issue. It was tied to gcloud install, virtualenv, gcloud config and the configuration of default authentication.

My gcloud had to be installed in the global namespace, and then my gcloud config worked in the venv.

Upvotes: 0

Bill Prin
Bill Prin

Reputation: 2518

Assuming you are using GAE Standard (not Flexible) the google-cloud-python client libraries can have some namespace issues, since it doesn't use virtualenv. There is currently work being done to make it a smoother experience.

One solution to fix your problem is to hack the import path. Take a look at my answer here.

However, if you're using GAE Standard, you don't need the client library at all. All Python logging statements like logging.info should automatically appear in Stackdriver Logging with the correct resource and labels set.

Upvotes: 1

Related Questions