question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: 'zoneinfo.ZoneInfo' object has no attribute 'zone'

See original GitHub issue

I am facing this error when I try to use calendar.

import datetime as dt
from O365 import Account, FileSystemTokenBackend
import os
import re

CLIENT_SECRET = 'xxxxxxx'
CLIENT_ID = 'xxxxxxxxxx'
TENANT_ID = 'xxxxxxxxxxxxxxx'
EMAIL_ID = 'xxxxxxxxxxxxxxx'

def calendar_event():
    credentials = (CLIENT_ID, CLIENT_SECRET)
    token_backend = FileSystemTokenBackend(token_path=os.getcwd(), token_filename='my_token.txt')
    account = Account(credentials, tenant_id=TENANT_ID, auth_flow_type='credentials', token_backend=token_backend)

    # Checking whether the client is authenticated.
    if not account.is_authenticated:
        try:
            account.authenticate()
            print('Authenticated!\n')
        except Exception as e:
            print("Exception: ", e)
            print("Authentication Failed!\n")
    else:
        print('Already Authenticated!\n')

    schedule = account.schedule(resource=EMAIL_ID)
    # print(schedule)

    calendar = schedule.get_default_calendar()
    print(calendar)

    new_event = calendar.new_event()  # creates a new unsaved event
    # print(new_event)
    new_event.subject = 'Recruit George Best!'
    new_event.location = 'England'

    # naive datetimes will automatically be converted to timezone aware datetime
    #  objects using the local timezone detected or the protocol provided timezone

    # new_event.start = datetime.now()
    new_event.start = dt.datetime(2021, 9, 7, 11, 45)

    # new_event.recurrence.set_daily(1, end=dt.datetime(2019, 9, 10))
    # new_event.remind_before_minutes = 45
    new_event.save()


if __name__ == '__main__':
    calendar_event()

The error I am facing

Traceback (most recent call last):
  File "C:\Users\karnayak\PycharmProjects\email_processing\calendar-processing.py", line 52, in <module>
    calendar_event()
  File "C:\Users\karnayak\PycharmProjects\email_processing\calendar-processing.py", line 35, in calendar_event
    new_event = calendar.new_event()  # creates a new unsaved event
  File "C:\Users\karnayak\PycharmProjects\email_processing\lib\site-packages\O365\calendar.py", line 1754, in new_event
Calendar: Calendar from Karthik Nayak (karthiknayak@gmail.com)
    return self.event_constructor(parent=self, subject=subject,
  File "C:\Users\karnayak\PycharmProjects\email_processing\lib\site-packages\O365\calendar.py", line 895, in __init__
    self.__recurrence = EventRecurrence(event=self,
  File "C:\Users\karnayak\PycharmProjects\email_processing\lib\site-packages\O365\calendar.py", line 137, in __init__
    get_windows_tz(self.protocol.timezone))
  File "C:\Users\karnayak\PycharmProjects\email_processing\lib\site-packages\O365\utils\windows_tz.py", line 639, in get_windows_tziana_tz.zone if isinstance(iana_tz, tzinfo) else iana_tz)
AttributeError: 'zoneinfo.ZoneInfo' object has no attribute 'zone'

Process finished with exit code 1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
janscascommented, Sep 8, 2021

I’ll try to release a new version today

0reactions
janscascommented, Sep 12, 2021

I’ll try to release a new version today

Done

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: 'backports.zoneinfo.ZoneInfo' object has no attribute ...
I'm getting an error message when trying to iterate though the calendar events. it then breaks out and give me no data.
Read more >
Python ExchangeLib is not working due to the backports ...
PYTZ_TO_MS_MAP[tz.zone][0] AttributeError: 'backports.zoneinfo.ZoneInfo' object has no attribute 'zone'. I tried to solve this but couldn't ...
Read more >
AttributeError: 'LocalTimezone' object has no attribute 'normalize'
Getting an error "AttributeError: 'LocalTimezone' object has no attribute 'normalize'" when trying to access irclogs. I'm running pytz 2008c, Python 2.5 on ...
Read more >
zoneinfo — IANA time zone support — Python 3.11.1 ...
If no file matching key is found, the constructor will raise ZoneInfoNotFoundError . The ZoneInfo class has two alternate constructors: classmethod ZoneInfo.
Read more >
backports.zoneinfo - PyPI
To get access to time zones with this module, construct a ZoneInfo object and attach it to your datetime: >>> from backports.zoneinfo import...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found