TypeError: Updater.__init__() got an unexpected keyword argument 'use_context'
Asked Answered
H

3

7

It occurred when I perform this :

updater = Updater('xyaz:testtsttttt-HI', use_context=True)

Many Thanks!

Holster answered 7/7, 2022 at 14:18 Comment(0)
S
14

"Down grade" or "upgrade" the python-telegram-bot to the relevant version , e.g i downgraded by using "pip install python-telegram-bot==13.7" from the lastest python-telegram-bot 20.0 version, and it worked for me, NOTE: my version might be different from yours so use the right version that wont call the error

Suttles answered 3/1, 2023 at 13:46 Comment(1)
Thanks for giving the version number. I stupidly got rid of the old version number from my req.txt & your answer saved me the trouble of trying a bunch of old version nos.Impure
H
7

You should revoke the token that you just posted. Also double check which version of python-telegram-bot you are using and followng the resources that PTB provides for that version.


Disclaimer: I'm currently the maintainer of python-telegram-bot.

Humfried answered 7/7, 2022 at 16:21 Comment(3)
Issue happening if we use v20. Can't it be fixed?Rath
@CakkMeStag What parameter is used instead of use_context in v20+?Jiggermast
@Rath you can fix the problem by using code that is compatible with the version of python-telegram-bot that you are using. @Jiggermast the use_context argument was dropped without replacement, because it no longer has any meaning.Humfried
I
0

I think this is a version related issue and I faced the same while I was using 20.6 version.I fixed this issue by using Application class instead of using Updater.

from telegram.ext import Application

application = Application.builder().token(TELEGRAM_API_TOKEN).build()

Later you can start the bot using application object.

application.run_polling()
Impersonal answered 16/10, 2023 at 21:51 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.