skip to Main Content

I tried:

  • pip install python-telegram-bot
  • pip3 install python-telegram-bot
  • pip install telegram
  • pip3 install telegram

But the error keeps showing up telling me there is no such package of ‘telegram.ext’ offered by python-telegram-bot.
However, my text editor with python plugin is able to find the package telegram.ext in my environment. I also tried using command prompt dirtectly on that virtual environment I created, still doesn’t work.
Seems that this same issue is faced by other posts on internet without any resolve.

my text editor plugin can find the package

4

Answers


  1. Chosen as BEST ANSWER

    I just realized the error was because there was another file named 'telegram.py' in the same directory causing the package import problem. Sorry for this silly mistake. Thank you and I will close the case.


  2. It seems both packages python-telegram-bot and telegram uses the same namespace "telegram". This can cause conflicts, so you should remove one of them.

    This uninstalls the telegram package

    pip uninstall telegram
    

    Note: use pip3 if on Linux or Mac

    Login or Signup to reply.
  3. Do 1-2 via terminal and 4 on your IDE:

    1. Install pip install telegram
    2. Install pip install python-telegram-bot
    3. If you are using a virtual environment, make sure it is activated
    4. Lastly, import from telegram.ext import
    Login or Signup to reply.
  4. If Python API for the tdlib library is being used then, as per Tutorial https://python-telegram.readthedocs.io/en/latest/tutorial.html Install the library:

    python3 -m pip install python-telegram
    

    (or simply python instead of python3 for some environments)

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