T
T
tds12892021-03-01 20:34:26
Python
tds1289, 2021-03-01 20:34:26

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

2 answer(s)
I
Igor Makhov, 2021-03-01
@tds1289

Because you need not OWM.weather_manager() but owm.weather_manager(). And you burned the token

J
John Norton, 2021-03-01
@John_Norton

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 question

Ask a Question

731 491 924 answers to any question