Feb-01-2022, 02:49 PM
In a previous thread, it was suggested I use pendulum to get daylight saving time information. At that time, I was having issues with my Python version. However, version 3.9.2 does have pendulum.
I must be misunderstanding the examples given in the Pendulum documentation or I'm still having version issues. I'm running Python3.9.2 on Jan 28, 2022 release of Raspberry OS on a RPi3B+
Just copying some examples from the documentation into a python3 program, I'm getting circular import issues. Also, the error indicates I'm trying to parse, but I don't have parse in my program.
What is it that I'm doing wrong or misunderstanding?
Below is the short program and then the errors.
I must be misunderstanding the examples given in the Pendulum documentation or I'm still having version issues. I'm running Python3.9.2 on Jan 28, 2022 release of Raspberry OS on a RPi3B+
Just copying some examples from the documentation into a python3 program, I'm getting circular import issues. Also, the error indicates I'm trying to parse, but I don't have parse in my program.
What is it that I'm doing wrong or misunderstanding?
Below is the short program and then the errors.
import pendulum # Gets the timezone instance print(pendulum.now().timezone) print(pendulum.now().tz) # Gets the timezone name print(pendulum.now().timezone_name) # Indicates if daylight savings time is on dt = pendulum.datetime(2012, 1, 1, tz='America/Toronto') print(dt.is_dst()) dt = pendulum.datetime(2012, 9, 1, tz='America/Toronto') print(dt.is_dst())
Error:pi@raspberrypi:~ $ python3 pendulum1.py
Traceback (most recent call last):
File "/home/pi/pendulum1.py", line 2, in <module>
import pendulum
File "/home/pi/pendulum.py", line 3, in <module>
dt = pendulum.parse('2012-09-05T23:26:11.123789')
AttributeError: partially initialized module 'pendulum' has no attribute 'parse' (most likely due to a circular import)
pi@raspberrypi:~ $