I’ve been working with telegram bot using python for a while and everything was fine, today i was starting to work on a new project but i got a lot of error abut python-telegram-bot library.. so i uninstall it and install it again and i tried a simple code like this below:
from telegram import Update
from telegram.ext import Updater, CommandHandler, MessageHandler, filters, CallbackContext, ConversationHandler
from telegram import KeyboardButton
def main():
updater = Updater(token="5934903868:AAGckQGHTbYwpAwdqGh9o5Zs2Hfdcb1PyZs")
dispatcher = updater.dispatcher
dispatcher.add_handler(CommandHandler('start', startCommand))
updater.start_polling()
updater.idle()
if __name__ == '__main__':
main()
but i keep getting this error :
init_() got an unexpected keyword argument ‘token’
Please help me i really need to solve this problem and continue with my project
2
Answers
Updater’s constructor method doesn’t accept that specific keyword argument. From the docs, it looks like Updater’s constructor accepts an argument bot, an instance of Bot, an object that can be initialized with token.
Try this
It appears that you are currently utilizing version
<=13.15
of thepython-telegram-bot
library. It’s worth noting that this library has undergone significant changes in version 20.0. To ensure compatibility and access to new features, it’s recommended to upgrade to version 20.0 by reviewing the release notes and the transition guide.If you wish to continue using your existing code, you can install version 13.15 via
pip install python-telegram-bot==13.15
. However, please be aware that this version is outdated and will no longer receive official support or bug fixes in the future. If you’re starting a new project, it is suggested to use version 20.0.