Install & Compatibility
Where this runs
tested against v0.0.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 33.5MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 3.1s · import 0.000s · 36MB
31MB installed
● package 31MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
bot
✓ from telebot import bot
✗ from telebot import TeleBot
This `telebot` package by KyleJamesWalker is distinct from the more popular `pyTelegramBotAPI` which typically uses `TeleBot` as its primary class.
handle_message
✓ from telebot import handle_message
✗ from telebot.ext import MessageHandler
This `handle_message` decorator is specific to the KyleJamesWalker/telebot library's routing mechanism, not to other Telegram bot libraries.
This quickstart demonstrates how to initialize the bot, define command handlers using decorators, and start the polling loop for the `KyleJamesWalker/telebot` library. Ensure you have a valid Telegram Bot Token from BotFather, ideally passed via an environment variable.
import os
from telebot import bot, handle_message
# This token should be obtained from BotFather on Telegram.
# For local testing, you can hardcode it, but for deployment use environment variables.
BOT_TOKEN = os.environ.get('TELEBOT_TOKEN', 'YOUR_BOT_TOKEN_HERE')
# Initialize the bot
my_bot = bot(BOT_TOKEN)
@handle_message("/start")
def start_command(message):
my_bot.post_message(message["chat"]["id"], "Hello! I am your simple bot.")
@handle_message("/hello")
def hello_command(message):
my_bot.post_message(message["chat"]["id"], "Hi there!")
@handle_message("default") # This acts as a fallback for any other message
def default_message(message):
my_bot.post_message(message["chat"]["id"], "I received: " + message["text"])
if __name__ == "__main__":
if BOT_TOKEN == 'YOUR_BOT_TOKEN_HERE':
print("WARNING: Please replace 'YOUR_BOT_TOKEN_HERE' with your actual bot token or set the TELEBOT_TOKEN environment variable.")
print("Starting KyleJamesWalker/telebot (version 0.0.5). Press Ctrl+C to stop.")
print("Using token ending in:", BOT_TOKEN[-4:])
# The run() method starts an infinite loop for polling
my_bot.run()
Debug
Known issues
breakingCritical Name Collision with `pyTelegramBotAPI`fixThis `telebot` package (KyleJamesWalker/telebot) is distinct from the more popular `pyTelegramBotAPI` (which is also imported as `telebot`). If you intended to use `pyTelegramBotAPI`, ensure you `pip install pyTelegramBotAPI` and use its corresponding API (e.g., `from telebot import TeleBot`). Do not mix code from both libraries, as they are incompatible.
affects: All versions (0.0.1-0.0.5)
deprecatedLibrary is Abandoned and Potentially OutdatedfixThis library has not been updated since 2018. It may not be compatible with current Telegram API changes, have unpatched security vulnerabilities, or contain bugs. Consider using a more actively maintained library like `pyTelegramBotAPI` or `python-telegram-bot` for robust applications.
affects: All versions (0.0.1-0.0.5)
gotchaBasic Error Handling and FeaturesfixThe library is minimalist and lacks many advanced features (e.g., file uploads, inline queries, webhook support, sophisticated error handling) that are common in more mature Telegram bot libraries. For advanced use cases, you may need to implement them manually or choose a more feature-rich library.
affects: All versions (0.0.1-0.0.5)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'telebot.TeleBot'
You installed `KyleJamesWalker/telebot` but are trying to use API calls (like `TeleBot` class) from the `pyTelegramBotAPI` library.
fixIf you intended to use `pyTelegramBotAPI`, run `pip uninstall telebot` and then `pip install pyTelegramBotAPI`. If you intended to use `KyleJamesWalker/telebot`, use `from telebot import bot` and `my_bot = bot(TOKEN)` instead.
AttributeError: 'TeleBot' object has no attribute 'handle_message'
You installed `pyTelegramBotAPI` but are trying to use the decorator-based routing (`@handle_message`) specific to the `KyleJamesWalker/telebot` library.
fixIf you intended to use `KyleJamesWalker/telebot`, run `pip uninstall pyTelegramBotAPI` and then `pip install telebot`. If you intended to use `pyTelegramBotAPI`, use its `bot.message_handler(commands=['start'])` decorator or similar methods instead of `@handle_message`.
TypeError: 'module' object is not callable
You have installed `KyleJamesWalker/telebot`, and its `bot` is a module, not a callable class named `TeleBot`.
fixIf you intended to use `KyleJamesWalker/telebot`, initialize it with `from telebot import bot; my_bot = bot(TOKEN)`. If you intended to use `pyTelegramBotAPI`, ensure it's installed (`pip install pyTelegramBotAPI`) and use `from telebot import TeleBot; my_bot = TeleBot(TOKEN)`.
Upgrade
Version history
0.0.5latest on PyPI · released Feb 14, 2023
Audit
Dependencies
requestsrequiredUsed for making HTTP requests to the Telegram API. Mentioned in release notes for v0.0.4.
Resources
No resource links recorded.