Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: cannot import name 'Filters' from 'telegram.ext'

I have installed python-telegram-bot like this:

pip install python-telegram-bot

And when I'm trying to do this:

from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackContext

I get this error:

ImportError: cannot import name 'Filters' from 'telegram.ext' (/home/mobitnlh/virtualenv/db_application/3.8/lib/python3.8/site-packages/telegram/ext/__init__.py)
like image 439
Adil Akram Avatar asked Nov 26 '25 11:11

Adil Akram


2 Answers

They made some changes, please see the link https://docs.python-telegram-bot.org/en/stable/telegram.ext.filters.html

Instead of

from telegram.ext import Filters

do

from telegram.ext import filters

and instead of Filters.all do filters.ALL

I hope it helps!

like image 183
Albina Nikiforova Avatar answered Nov 28 '25 16:11

Albina Nikiforova


According to their wiki, the name is filters. So just replace Filters with filters:

from telegram.ext import Updater, CommandHandler, MessageHandler, filters, CallbackContext
like image 20
Roj Avatar answered Nov 28 '25 16:11

Roj



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!