skip to Main Content
File "c:\TelegramBot\telegram.py", line 1, in <module>
import telegram.ext
ModuleNotFoundError: No module named 'telegram.ext'; 'telegram' is not a package

I had installed python telegram bot by using the command pip install python-telegram-bot
I tried many ways but still showing the same error. can u resolve this error

2

Answers


  1. I think your file name is “telegram.py”. Rename it to something else to see if the error fixes. Because python tries to import the file with that name. Also I assume that you have installed it in virtual environment. I you have not, please create a virtual environment and install the package again while the environment is activated.

    Login or Signup to reply.
  2. There are a few possible options:

    1. try renaming your file to something else than telegram, as telegram.py could interfere with the module.
    2. check if you’re using the correct Python version, maybe you just need to update it.
    3. the package may have been installed incorrectly, try uninstalling the module using pip uninstall python-telegram-bot, than reinstall it with pip install python-telegram-bot. Try doing it in the root folder of your project, then check if it’s actually installed doing pip show python-telegram-bot.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search