Answer the question
In order to leave comments, you need to log in
I am creating a telegram bot, but it gives an error TypeError: weather_manager() missing 1 required positional argument: 'self', what should I do?
I just recently started learning the PYTHON language, and programming in general, which is why I can't figure out what the problem is.
import telebot
from pyowm import OWM
from pyowm.utils.config import get_default_config
bot = telebot.TeleBot("", parse_mode=None)
config_dict = get_default_config()
config_dict['language'] = 'ru'
owm = OWM('')
@bot.message_handler(content_types=['text'])
def send_echo(message):
mgr = OWM.weather_manager()
observation = mgr.weather_at_place( message.text )
w = observation.weather
temp = w.temperature('celsius')["temp"]
answer = "В городе " + message.text + " сейчас " + w.detailed_status + "\n"
answer +="Температура около " + str( temp ) + " градусов цельсия." + "\n\n"
if temp < 10 :
answer += "На улице прохладно,нужна курточка."
elif temp < 20 :
answer += "В целом довольно тепло,можно и без куртки.)"
else:
answer += "Шорты и футболка-самое то =D."
bot.send_message(message.chat.id, answer)
bot.polling(none_stop=True)
#print(w)
Answer the question
In order to leave comments, you need to log in
Because you need not OWM.weather_manager() but owm.weather_manager(). And you burned the token
To be honest, I don't know this language, but I do know C#
Your problem is that you didn't put the self argument somewhere.
Another question for you, in which line is the error?
mgr = OWM.weather_manager()
Try to enter self here (in brackets)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question