skip to Main Content

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)

2

Answers


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

    from telegram.ext import Updater, CommandHandler, MessageHandler, filters, CallbackContext
    
    Login or Signup to reply.
  2. 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!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search