Message handler telegram bot ошибка

Вот такая ошибка: Traceback (most recent call last): File "C:/Users/User/PycharmProjects/trial3bot/tg.py", line 4, in @bot.message_handler(content_types=['text']) AttributeError: ...

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.

Already on GitHub?
Sign in
to your account


Closed

pypybeg opened this issue

Jan 12, 2018

· 25 comments

Comments

@pypybeg

Вот такая ошибка:
Traceback (most recent call last):
File «C:/Users/User/PycharmProjects/trial3bot/tg.py», line 4, in
@bot.message_handler(content_types=[‘text’])
AttributeError: ‘TeleBot’ object has no attribute ‘message_handler’

Удалил библиотеку telebot и обновил pytelegrambotapi

Буду рад вашей помощи,пользуюсь питоном третий день.

@MasterGroosha
MasterGroosha

changed the title
‘TeleBot’ object has no attribute ‘message_handler’ (Python) Самый новичок из новичков

‘TeleBot’ object has no attribute ‘message_handler’

Jan 12, 2018

@MasterGroosha

  1. Убедитесь, что все последующие действия совершаются именно для той версии Python, которой запускается бот.
  2. Если Python 3-й версии, то выполните pip3 uninstall telebot, затем pip3 install pytelegrambotapi --upgrade.
  3. Желательно перелогиниться или перезагрузиться.
atom1kk, IhorKosovych, aorgou, logvinenkas, pigel, nikolya98, Blucknote, VitalyGladyshev, Slezhuk, sshu-ya, and 16 more reacted with thumbs up emoji

@pypybeg

default
сделал как вы сказали,в первом случае ничего не удалило,так как ничего не обнаружило,а то еще раз обновилось.
но все равно та же ошибка :(

@MasterGroosha

File -> Settings -> Project Interpreter

У pyTelegramBotAPI какая версия указана в среднем столбце?

@pypybeg

@MasterGroosha

@pypybeg

@MasterGroosha

@pypybeg

default

@MasterGroosha

@pypybeg

@MasterGroosha

В таком случае, я уже не знаю, чем Вам помочь.
Судя по этому комментарию, telebot Вы не сразу удалили (хотя в первом сообщении писали обратное). Видимо, и здесь тоже что-то не то.
Если и после перезагрузки останутся хвосты telebot, попробуйте удалить дополнительно pyTelegramBotAPI и сразу же установить заново (всё там же в PyCharm).
Если и это не поможет — Вам на StackOverflow.

@pypybeg

@pypybeg

Ураа!))
Получилось,спасибо вам большое!)

@MasterGroosha

@blendedw

@evgeniygazetdinov

вот поэтому не нужно пользоваться pycharm.vim + терминал

@atom1kk

  1. Убедитесь, что все последующие действия совершаются именно для той версии Python, которой запускается бот.
  2. Если Python 3-й версии, то выполните pip3 uninstall telebot, затем pip3 install pytelegrambotapi --upgrade.
  3. Желательно перелогиниться или перезагрузиться.

Спасибо, помогло)

@jenjajenjaBot

Безымянный
что делать, помогите плз(

@MasterGroosha

mouse1500, Burdeinick, and-semakin, Slezhuk, sukhrobbek, Gr1z-zly, JaneKhus, YaWasabi, CookieMonster79, and velencie reacted with thumbs up emoji
Wedyarit, meth1337, and h2sm reacted with laugh emoji

@jenjajenjaBot

@jenjajenjaBot попробуйте вместо массажа использовать сообщение

в смысле?
вместо сообщения использывать сообщение?

@MasterGroosha

kali-ui, lzrdblzzrd, basilik52, hntirgeam, fullshow1337, CyberEssence, Armaniooo, kuksag, Burdeinick, l1naqou, and 15 more reacted with laugh emoji

@ibro187

@MasterGroosha

@ibro187

2. pip3 uninstall telebot

я застрял на телеграмм боте ошибка пуля в пулю как у человека который создал эту тему
а еще я использую мак

@MasterGroosha

Repository owner

locked as off-topic and limited conversation to collaborators

Nov 28, 2021

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import telebot
from telebot import types
 
 
token = ''
bot = telebot.TeleBot(token)
 
 
@bot.message_handler(commands=['vaif'])
def welcome(message):
 
    markup_reply = types.ReplyKeyboardMarkup()
    item_hi = types.KeyboardButton('Привет')
    item_bye = types.KeyboardButton('Пока')
 
    markup_reply.add(item_hi, item_bye)
    bot.send_message(message.chat.id,  "Добро пожаловать, {0.first_name}!nЯ - <b>{1.first_name}</b>, создан служить господину.".format(message.from_user, bot.get_me()), parse_mode = 'html', reply_markup = markup_reply)
 
 
@bot.message_handler(content_types=['text'])
def answer(message):
    if message.text == 'Привет':
        markup_reply = types.InlineKeyboardMarkup(row_width=2)
        item_pic = types.InlineKeyboardButton(text = 'картинка', callback_data = 'pic')
        item_audio = types.InlineKeyboardButton(text = 'песенка', callback_data = 'aud')
 
        markup_reply.add(item_pic,  item_audio)
        bot.send_message(message.chat.id, 'Могу я для вас что-то сделать господин?', reply_markup=markup_reply)
    elif message.text == 'Пока':
        bot.send_message(message.chat.id, 'Хорошо господин')
 
@bot.callback_query_handler(func=lambda call: True)
def answer1(call):
    if call.data == 'pic':
        markup_reply = types.ReplyKeyboardMarkup(resize_keyboard=True)
        pic1 = types.KeyboardButton('Топ Вайфу')
        pic2 = types.KeyboardButton('Даня')
        pic3 = types.KeyboardButton('Люблю тебя')
 
        markup_reply.add(pic1, pic2, pic3)
        bot.send_message(call.message.chat.id, 'Выбирайте из этого господин:3', reply_markup=markup_reply)
    elif call.data == 'aud':
        markup_reply = types.ReplyKeyboardMarkup(resize_keyboard=True)
        mus1 = types.KeyboardButton('Для гулей')
        mus2 = types.KeyboardButton('Тёма лув')
        mus3 = types.KeyboardButton('Топ чартов')
 
        markup_reply.add(mus1, mus2, mus3)
        bot.send_message(call.message.chat.id, 'Выбирай из этого:3', reply_markup=markup_reply)
 
 
@bot.message_handler(content_types=['text'])
def get_text_messages1(message):
    if message.text == 'Для гулей':
        bot.send_message(message.from_user.id, 'https://open.spotify.com/track/1ghdJUMhmLEpUitNwyNMWH?si=675eb5a3e48a4bf9')
    elif message.text == 'Тёма лув':
        bot.send_message(message.from_user.id, 'https://open.spotify.com/track/6H167kbd8gY2Eewzf14YjD?si=91eeba1c6cb84fab')
    elif message.text == 'Топ Чартов':
        bot.send_message(message.from_user.id, 'https://open.spotify.com/track/6t1ODAVbCVRQas6OyaGXQP?si=310d99fcbba14620')
    elif message.text == 'Топ Вайфу':
        bot.send_message(message.from_user.id, 'http://pm1.narvii.com/6869/e39b5e83a446fea0446a062013de105540e07259r1-1152-650v2_uhq.jpg')
    elif message.text == 'Даня':
        bot.send_message(message.from_user.id, 'https://sun9-3.userapi.com/impg/zeZga0qpRDMkepm-GpdOJMc2rV0EtgRObACuww/s99uG5QfDM4.jpg?size=949x945&quality=96&sign=49fc693c5cfacadb6ed3a4ad5000e44c&type=album')
    elif message.text == 'Люблю тебя':
        bot.send_message(message.from_user.id, 'https://sun9-49.userapi.com/impg/oFPZAbfD2cde7LK0iSMpD1-ckCC7W-tzCqrQwg/0O4DSdMBwpc.jpg?size=1200x1600&quality=96&sign=a9c7b4dfb057f20bcda450f7037d63c7&type=album')
    else:
        bot.send_message(message.from_user.id, 'похоже вы нажали куда-то не туда :3')
 
 
bot.polling(none_stop=True, interval=0)

Problems with using PyTelegramBotAPI

I`m trying to make a simple telegram bot, but I have a problem. I’ve installed all necessary modules using bash as you can see, but I got AttributeError: ‘TeleBot’ object has no attribute ‘message_handler’ and if I use sys.modules() while running main file — there is no pytelegrambotapi module. How can I fix it?

from flask import Flask, request
import telebot

token = '1061.........FRozpkKCROV2Cs'
bot = telebot.TeleBot(token)
app = Flask(__name__)

@app.route('/', methods=["POST"])
def webhook():
    bot.process_new_updates([telebot.types.Update.de_json(request.stream.read().decode("utf-8"))])
    return "!", 200

@bot.message_handler(commands=['start'])
def command(message):
    bot.send_message(message.chat.id, 'Hi, ' + message.chat.first_name + '!')

deleted-user-6791077
|
3
posts
|



Jan. 22, 2020, 9:39 p.m.

|
permalink

sounds like perhaps a version mismatch?

Staff

conrad
|
4233
posts
|

PythonAnywhere staff
|



Jan. 23, 2020, 11:44 a.m.

|
permalink

I’ve created new environment and use «#!usr/venv_new/bin/python3.8», but the problem wasn’t solved. Is there any problems with package pytelegrambotapi? On my pc this code works.

deleted-user-6791077
|
3
posts
|



Jan. 23, 2020, 7:51 p.m.

|
permalink

is this the same error message? also is this a webapp? in which case the hashbang method wouldn’t work- you would need to configure it in the webapp virtualenv section and then reload your webapp.

Staff

conrad
|
4233
posts
|

PythonAnywhere staff
|



Jan. 24, 2020, 10:42 a.m.

|
permalink

I did:

pip install PyTelegramBotAPI==2.2.3
pip install PyTelegramBotAPI==3.6.7

And now everything works, so you were right, it was version mismatch. Thank you for your help)

deleted-user-6791077
|
3
posts
|



Jan. 25, 2020, 12:20 a.m.

|
permalink

Excellent, glad you got it working!

Staff

giles
|
11190
posts
|

PythonAnywhere staff
|



Jan. 25, 2020, 5:42 p.m.

|
permalink

I have error
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: ‘/usr/local/lib/py
thon2.7/dist-packages/pyTelegramBotAPI-3.6.7.dist-info’
Consider using the --user option or check the permissions.

deleted-user-8331532
|
4
posts
|



Oct. 14, 2020, 10:01 a.m.

|
permalink

i try to install
pip install PyTelegramBotAPI==2.2.3
pip install PyTelegramBotAPI==3.6.7

deleted-user-8331532
|
4
posts
|



Oct. 14, 2020, 10:07 a.m.

|
permalink

We have a help page that covers how to install modules.

Staff

glenn
|
8703
posts
|

PythonAnywhere staff
|



Oct. 14, 2020, 10:16 a.m.

|
permalink

Glenn, thank you so much!

deleted-user-8331532
|
4
posts
|



Oct. 14, 2020, 11:20 a.m.

|
permalink

Понравилась статья? Поделить с друзьями:
  • Message handler telegram bot error
  • Message frameworkevent error stack 0
  • Message fatal system error
  • Message fatal error cannot set display mode
  • Message error syntax error at or near