I am a beginner with python-telegram-bot, I have installed version the latest version 20.2.
I installed a package "python-telegram bot" but I got an import error upon running the code
ImportError: cannot import name "Dispatcher" from telegram.ext
I delved into the python-telegram-bot package and discovered that there is no module called Dispatcher, but several online tutorials directly imported Dispatcher from telegram.ext.
In my attempt to build a bot using Telegram, I have tried several times, but I have still received a message that says it cannot import the name ‘Dispatcher’ from the extension telegram.ext.As far as I am concerned, this error should be solved as soon as possible and I would appreciate if you could help me with it.
2
Answers
You seem to be using a version >=20.0 of python-telegram-bot but your code is written for version <=13.15. Please either upgrade your code to v20 by reading the release notes and the transition guide or install a version of PTB that is compatible with your code base.
Please note that the PTB team does not provide support for versions older than v20 anymore.
Disclaimer: I’m currently the maintainer of
python-telegram-bot
.According to the latest documentation suggested by @CallMeStag, you need to do some tweaking to your code lol. There’s a lot of upgrade happening with the api. Here is a sample code i tried: