csparpa / pyowm

A Python wrapper around the OpenWeatherMap web API
https://pyowm.readthedocs.io
MIT License
790 stars 172 forks source link

colab and pyowm #434

Open bbking78 opened 6 months ago

bbking78 commented 6 months ago

hi, not sure if this is the right place to ask, so pls bear with me.... I am playing aroung with pyowm in colab - works partly but I am a bit confused. OWM billing plan: One Call API 3.0 free for 1000 request daily, afterwards 0.14 per 100 calls. (credit card added)

installed pyowm:

#!pip3 install pyowm
print("OWM Version: " + str(owm.version)) gives me
OWM Version: (3, 3, 0)

this works:

owm = OWM('<API-Key>')
mgr = owm.weather_manager()
daily_forecast = mgr.forecast_at_place('London,GB', 'daily')
for x in range(0,23):
  print("x is: " + str(x))
  tomorrow_at_time = timestamps.tomorrow(x, 0)                      # datetime object for tomorrow at 5 PM
  weather = daily_forecast.get_weather_at(tomorrow_at_time)
  print(weather.temperature(unit='celsius'))

it prints 23x the same values, like: {'day': 13.85, 'min': 8.79, 'max': 14.12, 'night': 9.75, 'eve': 11.67, 'morn': 8.79, 'feels_like_day': 12.86, 'feels_like_night': 7.15, 'feels_like_eve': 10.96, 'feels_like_morn': 7.09}

so somehow not a daily forecast....

when trying OneCall 3.0 to stay up to date: one_call=mgr.one_call(lat=52.5244, lon=13.4105)

it gives me

UnauthorizedError: Invalid API Key provided

but when I call this in a browser, this works: https://api.openweathermap.org/data/3.0/onecall?lat=52.5244&lon=13.4105&units=metric&appid=API-key

what is wrong here, so that I cannot use the one_call function calls from pyowm? thanks in advance!