Answer the question
In order to leave comments, you need to log in
I can not specify the Russian language, how to fix it?
there is a code
import pyowm
city = input("Какой город вас интересует?: ")
owm = pyowm.OWM('a99967bc9ee70d5b4bd387902982f400', language = "RU")
observation = owm.weather_at_place(city)
w = observation.get_weather()
temperature = w.get_temperature('celsius')['temp']
print("В городе " + city + " сейчас температура: " + str(temperature) + " по Цельсию.")
print('Погода в указаном городе: ' + w.get_detailed_status())
Answer the question
In order to leave comments, you need to log in
For pyOWM 3.0.0, a config is required.
Source
Something like:
import pyowm
from pyowm.commons.enums import SubscriptionTypeEnum
from pyowm.utils.measurables import kelvin_to_celsius
city = 'Krasnodar'
config = {
'subscription_type': SubscriptionTypeEnum.FREE,
'language': 'ru',
'connection': {
'use_ssl': True,
'verify_ssl_certs': True,
'use_proxy': False,
'timeout_secs': 5
},
'proxies': {
'http': 'http://user:[email protected]:port',
'https': 'socks5://user:[email protected]:port'
}
}
owm = pyowm.OWM('a99967bc9ee70d5b4bd387902982f400', config=config)
mgr = owm.weather_manager()
observation = mgr.weather_at_place(city)
w = observation.weather
print("В городе " + city + " сейчас температура: " + str(kelvin_to_celsius(w.temp['temp'])) + " по Цельсию.")
print('Погода в указаном городе: ' + observation.location.name)
This code (but with my key) works for me without changes, Python 3.
Try reinstalling pyowm
I did not understand what the above answers are about, of course, except for one.
There is no keyword language, it is written. I don’t know where you got the 3.0 version of the library from, I got 2.10 with an update. Perhaps I just have a lower version of python than I need.
Anyway,
class OWM:
"""
Entry point class providing ad-hoc API clients for each OWM web API.
:param api_key: the OWM API key
:type api_key: str
:param config: the configuration dictionary (if not provided, a default one will be used)
:type config: dict
"""
def __init__(self, api_key, config=None):
assert api_key is not None, 'API Key must be set'
self.api_key = api_key
if config is None:
self.config = cfg.get_default_config()
else:
assert isinstance(config, dict)
self.config = config
owm = pyowm.OWM('a99967bc9ee70d5b4bd387902982f400', {'language': 'ru'})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question