-1

I am facing this error and I do not know how to solve it and I think I have written my code correctly

File "C:\Users\Revenger\index.py", line 1, in <module>
        from pyrogram import Client, Filters
    ImportError: cannot import name 'Filters' from 'pyrogram' (C:\Users\Revenger\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pyrogram\__init__.py)

This is my Code

from pyrogram import Client, filters
from pyrogram.methods.chats.get_chat_members import Filters

app = Client("Client", bot_token="Token")

@app.on_message(Filters.private & Filters.command('start'))
def startmsg(client, message):
    message.reply("Hi Wassimo Bot is Here")


app.run()  #"long-polling"
  • Isn't it a typo? In the documentation it's without capital letter, the stacktrace shows `Filters`. – William May 21 '21 at 13:44
  • You're importing the correct `filters`, but then import and use another `Filters` from some random place. Use just `filters`. – ColinShark May 21 '21 at 13:59

2 Answers2

0

use filters instead of Filters

from pyrogram import filters, Client

delete second line , becouse you are importing Filters from random place

amiralirj
  • 103
  • 1
  • 8
0

import methods relative to version

in old versions:

from pyrogram import Filters
from pyrogram.types import InlineKeyboardMarkup # Example

in newer version:

from pyrogram import filters
from pyrogram import InlineKeyboardMarkup # Example