Import Error: Google Analytics API Authorization

FreeSid91 picture FreeSid91 · Mar 1, 2016 · Viewed 9.6k times · Source

I'm trying to run the sample provided here https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/service-py for authorization.

I've noticed from other questions in SO that (ImportError: cannot import name SignedJwtAssertionCredentials) SignedJwtAssertionCredentials has been removed and therefore could not be imported.

So, I started to follow the solutions provided both on the GitHub page (https://github.com/google/oauth2client/issues/401) and StackOverflow. So far, nothing worked, I'm still seeing the same error. Following is my code.

import argparse

from apiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials

import httplib2
from oauth2client import client
from oauth2client import file
from oauth2client import tools

And, this is the error I'm receiving on running the above code.

ImportError: cannot import name ServiceAccountCredentials

As I'm a complete newbie in this space, I tried to do this for both versions of OAuth (2.0.0 and 1.5.2). I also tried it after installing pyopenssl, but still failed.

Answer

schafle picture schafle · Mar 1, 2016

It seems oauth2client installation is unsuccessful. Try

pip install --upgrade google-api-python-client