Не могу настроить Библиотеку PyOWM чтобы выдавала прогноз погоды на завтра. Выходит ошибка:

Рейтинг: 0Ответов: 0Опубликовано: 29.01.2023

Traceback (most recent call last): File "/Users//PycharmProjects/pythonProject/weather.py", line 24, in fc = mgr.ocation_for(city) AttributeError: 'WeatherManager' object has no attribute 'ocation_for'

**Пишет ошибка в модуле, ставил значения daily_forecaster = mgr.forecast_at_place('city') но опять же выдает ошибку, очень нужна ваша помощь. **

cам код:

import data as data
from pyowm import OWM
from pyowm.utils import config
from pyowm.utils import timestamps
import requests
import datetime
from pyowm.utils.config import get_default_config

city = input('Введите название города: ')

config_dict = get_default_config()
config_dict['language'] = 'ru'
owm = OWM('654184420fe38a7207b77ad41ecf8c55', config_dict)
mgr = owm.weather_manager()
observation = mgr.weather_at_place(city)
weather = observation.weather
sunrise_date = weather.sunrise_time(timeformat='date')
sunrset_date = weather.sunset_time(timeformat='date')
weather = mgr.weather_at_place(city).weather
temp_dict_celsius = weather.temperature('celsius')
wind_dict_in_meters_per_sec = observation.weather.wind()
observation = mgr.weather_at_place(city)
w = observation.weather
fc = mgr.ocation_for(city)
forecast = fc.get_forecast()
weekday = w.get_reference_time('date').strftime("%A")

# print(w)

now = datetime.datetime.now()
tomorrow = now + datetime.timedelta(days=1)
tomorrow_timestamp = int(tomorrow.timestamp())

tomorrow_weather = None
for weather in forecast:
    if weather.get_reference_time() == tomorrow_timestamp:
        tomorrow_weather = weather
        break

description = w.status

if "clear" in description.lower():
    description += " ☀️"
elif "cloud" in description.lower():
    description += " ☁️"
elif "rain" in description.lower():
    description += " ☔️"
elif "snow" in description.lower():
    description += " ❄️"
elif "fog" in description.lower():
    description += " 🌫"

# time = sunrise_date.strftime("%I:%M %p")
# time_reversed = time[:5][::-1] + " " + time[:5][::-1]

print('Погда в городе ' + str(city) + ' сегодня ' + str(description) + "!")
print('Восход:' + sunrise_date.strftime("%H:%M %d.%m.%Y"))
print('Заход:' + sunrset_date.strftime("%H:%M %d.%m.%Y"))
print('Температура: ' + str(temp_dict_celsius['temp']) + ' С°')
print('Ветер: ' + str(wind_dict_in_meters_per_sec['speed']) + ' м/с')

tom = input('Желаете узнать погоду на завтра? ДА/НЕТ')
if tom.lower() == "да":
    print("Today is: " + str(weekday))
    print("Tomorrow's weather in" + str(city))
    print("Weather status: " + tomorrow_weather.get_status())
else:
    print('*****Желаем хорошего дня!*****')

Ответы

Ответов пока нет.