Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1255

Python • problems with Astral

$
0
0
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 with

Code:

sudo apt install python3-astral
Then my script starts with

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,    )
The first error is with the importing of Observer
ImportError: cannot import name 'Observer' from 'astral' (/usr/lib/python3/dist-packages/astral.py)
When I delete this line, I get an error for importing sun (next line)
ModuleNotFoundError: Module named 'astral.sun'; 'astral' is not a package
I tried looking for a solution, and I ended at this page https://sffjunkie.github.io/astral/
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"))
I just get a similar error: Location.info cannot be imported.

Can anyone help me solve this problem?

Statistics: Posted by diedhert — Sat Mar 15, 2025 6:07 pm



Viewing all articles
Browse latest Browse all 1255

Trending Articles