csparpa / pyowm

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

Not working #414

Closed ruslan304 closed 1 year ago

ruslan304 commented 1 year ago

from pyowm import OWM from pyowm.utils import config from pyowm.utils import timestamps from pyowm.utils.config import get_default_config owm = OWM('3a6261216d2cd7d6ecb6aafe27b1fdb8') # You MUST provide a valid API key config_dist = get_default_config() config_dist['language'] = 'ru'

place = input('wrote a your city')

Search for current weather in London (Great Britain)

mgr = owm.weather_manager() observation = mgr.weather_at_place(place) w = observation.weather temp = w.temperature('celsius') ['temp'] tempmin = w.temperature('celsius')['temp_min'] tempmax = w.temperature('celsius')['temp_max'] cloud = w.detailed_status clouds = w.clouds wind = w.wind()['speed'] winds = w.wind()['deg'] daily_forecaster = mgr.forecast_at_place('Berlin,DE' 'daily') tomorrow = timestamps.tomorrow() # datetime object for tomorrow weather = daily_forecaster.get_weather_at(tomorrow)

print(w) print('Погода сейчас такая: ' + cloud + str(clouds)) print('Приблизна температура:' + str(temp)) print('Максимальна температура:' + str(tempmax)) print('Мінімальна температура:' + str(tempmin)) print('скорость ветра='+ str(wind)) print('угол ветра='+ str(winds)) if temp < 10: print('Одягай теплі вещі') elif temp < 20: print('Можна в худі') elif temp > 20: print('Літо, шорти') input('Щоб закрити програму нажміть Enter') print(weather)

the error line 21, in daily_forecaster = mgr.forecast_at_place('Berlin,DE' 'daily') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: WeatherManager.forecast_at_place() missing 1 required positional argument: 'interval'

csparpa commented 1 year ago

You seem to be missing a comma (,) to separate arguments

Instead of: daily_forecaster = mgr.forecast_at_place('Berlin,DE' 'daily')

do: daily_forecaster = mgr.forecast_at_place('Berlin,DE' , 'daily')