Hi all
I experience some problems with using 'astral'.
To start with: raspberry pi is new, and I have a very basic knowledge.
I started withThen my script starts withThe first error is with the importing of Observer
But when I copy a part of this pageI just get a similar error: Location.info cannot be imported.
Can anyone help me solve this problem?
I experience some problems with using 'astral'.
To start with: raspberry pi is new, and I have a very basic knowledge.
I started with
Code:
sudo apt install python3-astral
Code:
import pandas as pdimport datetime import datetimeimport timeimport osfrom typing import Optionalfrom astral import Observerfrom astral.sun import sunfrom picamera import PiCamera# location settingslat: float = 51.039363lon: float = 2.593612tz: str = 'utc' # preferably to avoid issues when daylight savings time starts/end# create an astral observerobserver = Observer( latitude=lat, longitude=lon, timezone=tz, )
When I delete this line, I get an error for importing sun (next line)ImportError: cannot import name 'Observer' from 'astral' (/usr/lib/python3/dist-packages/astral.py)
I tried looking for a solution, and I ended at this page https://sffjunkie.github.io/astral/ModuleNotFoundError: Module named 'astral.sun'; 'astral' is not a package
But when I copy a part of this page
Code:
from astral import LocationInfocity = LocationInfo("London", "England", "Europe/London", 51.5, -0.116)print(( f"Information for {city.name}/{city.region}\n" f"Timezone: {city.timezone}\n" f"Latitude: {city.latitude:.02f}; Longitude: {city.longitude:.02f}\n"))
Can anyone help me solve this problem?
Statistics: Posted by diedhert — Sat Mar 15, 2025 6:07 pm