How do I import the missing library? Google Calendar Python API

Asked

Viewed 49 times

0

I’m trying to insert events in Google calendar, via Python script, but I think a library is missing, because when I run the script the following error appears

name error named 'service' is not defined

Script I am running

event = {
  'summary': 'Google I/O 2015',
  'location': '800 Howard St., San Francisco, CA 94103',
  'description': 'A chance to hear more about Google\'s developer products.',
  'start': {
    'dateTime': '2020-05-28T09:00:00-07:00',
    'timeZone': 'America/Brasil',
  },
  'end': {
    'dateTime': '2015-05-28T17:00:00-07:00',
    'timeZone': 'America/Brasil',
  },
  'recurrence': [
    'RRULE:FREQ=DAILY;COUNT=2'
  ],
  'attendees': [
    {'email': '[email protected]'},
    {'email': '[email protected]'},
  ],
  'reminders': {
    'useDefault': False,
    'overrides': [
      {'method': 'email', 'minutes': 24 * 60},
      {'method': 'popup', 'minutes': 10},
    ],
  },
}

event = service.events().insert(calendarId='primary', body=event).execute()
print('evento criado com sucesso')

Can anyone help me?? Please do not exclude my question

  • Put the whole code, by mistake you’re saying that the service is not declared!

1 answer

0

If this is your entire code, it is missing to load Ibraries and instantiate service

Something like:

from googleapiclient.discovery import build

service = build('calendar', 'v3', credentials=<SUA_CREDENCIAL_AQUI>)

Take a look at documentation theirs

I hope it helps

Browser other questions tagged

You are not signed in. Login or sign up in order to post.