1

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 -

FObersteiner
  • 22,500
  • 8
  • 42
  • 72
AKSHAY KADAM
  • 129
  • 8

0 Answers0