2

I am trying to import pytz module to get timezone.. but the code doesn't seem to be working as expected and it is throwing some ModuleNotFoundError exception which i think are dependent to pytz module internally

My Code

import pytz
import datetime

local_tz = pytz.timezone("America/Los_Angeles")
time = datetime.datetime.now(local_tz)
print(time)

Error Being thrown :

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pytz/lazy.py", line 3, in <module>
    from UserDict import DictMixin
ModuleNotFoundError: No module named 'UserDict'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/elastic/samptest.py", line 1, in <module>
    import pytz
  File "/usr/lib/python3/dist-packages/pytz/__init__.py", line 19, in <module>
    from pytz.lazy import LazyDict, LazyList, LazySet
  File "/usr/lib/python3/dist-packages/pytz/lazy.py", line 5, in <module>
    from collections import Mapping as DictMixin
ImportError: cannot import name 'Mapping' from 'collections' (/usr/lib/python3.10/collections/__init__.py)

Python Version - 3.10.9

Any suggestion or help to debug this is greatly appreciated.. Thank you -

2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.