Google-api-python-client: Error importing discovery from the client API

Created on 24 Aug 2016  路  7Comments  路  Source: googleapis/google-api-python-client

Hello, I'm getting a name exception when running a simple script. I've tried running the script in two ways:

from apiclient import discovery
import json

from pprint import pprint
from httplib2 import Http

from oauth2client.service_account import ServiceAccountCredentials

scopes = ['https://www.googleapis.com/auth/fusiontables']

credentials = ServiceAccountCredentials.from_json_keyfile_name(
    'service-account.json', scopes)

ft = discovery.build('fusiontables', 'v2', credentials=credentials)
pprint(ft)

Which gives:

Traceback (most recent call last):
File "apiTest.py", line 1, in
from apiclient import discovery
File "build/bdist.linux-x86_64/egg/apiclient/init.py", line 18, in
File "build/bdist.linux-x86_64/egg/googleapiclient/channel.py", line 64, in
ImportError: cannot import name util

And:

from apiclient.discovery import build
import json

from pprint import pprint
from httplib2 import Http

from oauth2client.service_account import ServiceAccountCredentials

scopes = ['https://www.googleapis.com/auth/fusiontables']

credentials = ServiceAccountCredentials.from_json_keyfile_name(
    'service-account.json', scopes)

ft = discovery.build('fusiontables', 'v2', credentials=credentials)
pprint(ft)
#print response

Which yields the same exception:

python apiTest.py
Traceback (most recent call last):
File "apiTest.py", line 1, in
from apiclient.discovery import build
File "build/bdist.linux-x86_64/egg/apiclient/init.py", line 18, in
File "build/bdist.linux-x86_64/egg/googleapiclient/channel.py", line 64, in
ImportError: cannot import name util

I'm not sure if I'm missing a prereq or what, but I'm not able to find a way around this.

triage me bug

Most helpful comment

Is this fixed? I am still seeing this error...

Using google-api-python-client 1.6.2 with oauth2client 4.1.1

All 7 comments

What version are you on? This seems like the oauth2client compatibility issue that was fixed in 1.5.2.

I'm on 1.5.2.

In fact, I just cloned in today.

What version of oauth2client are you using?

oh no, I just realized I missed one: https://github.com/google/google-api-python-client/blob/master/googleapiclient/channel.py#L64

That line just needs to be removed. I'll try to get a PR and new release in this week.

Thanks so much!

Is this fixed? I am still seeing this error...

Using google-api-python-client 1.6.2 with oauth2client 4.1.1

Was this page helpful?
0 / 5 - 0 ratings