skip to Main Content

I’m trying to use the example codes from the repository’s beginners guide and the ready-made examples:
wiki&
examples

I can’t run them because of some classes that can’t be imported. I’m using Visual Studio and when debugging, find the following error

from telegram.ext import (
    Application,
    CallbackContext,
    CommandHandler,
    ConversationHandler,
    MessageHandler,
    filters,
)

gives this error

cannot import name 'Application' from 'telegram.ext'

Was it my mistake? I uninstalled and installed using pip, the error keeps showing up

2

Answers


  1. I think you haven’t installed it correctly .

    try installing it with setup.py in order to do that just follow these steps

    1- git clone "repository link"

    2- cd python-telegram-bot

    3- py setup.py install or python setup.py install

    Your code has no problem.
    if you encountered and error while doing this please do comment.

    Login or Signup to reply.
  2. You are installing the alpha version which has a lot of changes.
    To fix this issue:

    1. Uninstall PTB v20
    2. Install latest PTB stable version (which is version 13) using: pip install python-telegram-bot
    3. use this version of documentation for a tutorial on how to write your first bot.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search