pyTelegramBotAPI import error: AttributeError: module ‘telebot’ has no attribute ‘TeleBot’

项月亮
1 min readOct 6, 2019

--

Under normal circumstances, Python script calls pyTelegramBotAPI module with “import”:

import telebotdef telebot_send(message):
bot = telebot.TeleBot(TOKEN)
bot.send_message(chat_id, message)

But sometimes a special error will occur: AttributeError: module ‘telebot’ has no attribute ‘TeleBot’. Two situations will result in this error.

  1. The same name python file called “telebot.py” exists under the same directory. “import telebot” will import the file rather than the module;

Solution

Rename the “telebot.py”.

2. A familiar module “telebot” also exists in Pypi. If someone wrongly installed it with “pip3 install telebot” instead of pyTelegramBotAPI, python script will import a different module that doesn’t have the attribute.

Solution

pip3 uninstall telebot
pip3 install pyTelegramBotAPI

Uninstalling the pyTelegramAPI is necessary, then reinstall the pyTelegramBotAPI module, it will working without attribute error.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Responses (2)

Write a response