Forums

Google api

I have been trying to learn how to use the google api for calendar integration. I had the quickstart example working last night as per the link below (except I had to build the credentials on my own computer).

https://developers.google.com/drive/api/v3/quickstart/python

This morning I am getting the error "ImportError: cannot import name 'build'". I have tried updating the modules but still the same responce. Has something changed, am I missing something, or have I inadvertantly messed up (I am fairly sure it is exactly the same code I am running this morning as last night)?

Cheers,

Adam

What command did you use to install the upgraded Google API modules? What did it print out?

Hi Giles, thanks for getting back to me.

I used the following to upgrade the modules:

pip3.6 install --upgrade google-api-python-client oauth2client

and the output I get is:

Traceback (most recent call last):
  File "quickstart.py", line 3, in <module>
    from googleapiclient.discovery import build
  File "/home/aj020883/.local/lib/python3.6/site-packages/googleapiclient/discovery.py", line 32, in <module>
    from six.moves import http_client
  File "/home/aj020883/.local/lib/python3.6/site-packages/six.py", line 92, in __get__
    result = self._resolve()
  File "/home/aj020883/.local/lib/python3.6/site-packages/six.py", line 115, in _resolve
    return _import_module(self.mod)
  File "/home/aj020883/.local/lib/python3.6/site-packages/six.py", line 82, in _import_module
    __import__(name)
  File "/usr/lib/python3.6/http/client.py", line 71, in <module>
    import email.parser
  File "/usr/lib/python3.6/email/parser.py", line 12, in <module>
    from email.feedparser import FeedParser, BytesFeedParser
  File "/usr/lib/python3.6/email/feedparser.py", line 27, in <module>
    from email._policybase import compat32
  File "/usr/lib/python3.6/email/_policybase.py", line 9, in <module>
    from email.utils import _has_surrogates
  File "/usr/lib/python3.6/email/utils.py", line 33, in <module>
    from email._parseaddr import quote
  File "/usr/lib/python3.6/email/_parseaddr.py", line 16, in <module>
    import time, calendar
  File "/home/aj020883/mealplanner/calendar.py", line 3, in <module>
    from googleapiclient.discovery import build
ImportError: cannot import name 'build

any ideas where i am going wrong?

Cheers,

Adam

I have got it working now. I had put a file called 'calendar.py' in the same folder as what I was trying to run which broke it.

Cheers,

Adam

Ah, that would explain it! Glad you worked it out.