skip to Main Content

I’m trying to use python-telegram-bot. (The version of python is 3)
I installed it using
pip install python-telegram-bot

I run a file with the next code:

from telegram import Updater

And I get the next error:

Traceback (most recent call last):
File "pyStart.py", line 1, in <module>
from telegram import Updater
ModuleNotFoundError: No module named 'telegram'

Even when using from python-telegram-bot, I get an error

File "pyStart.py", line 1
from python-telegram-bot import Updater
           ^
SyntaxError: invalid syntax

What causes the error?

2

Answers


  1. I think you installed your package in Python2 packages. Try using: pip3 install python-telegram-bot for Python 3 environment.

    Login or Signup to reply.
  2. Try installing it with pip3:

    pip3 install python-telegram-bot
    

    If that’s not working:

    python3 -m pip install python-telegram-bot
    

    If you don’t have pip3, you can install it with this command:

    sudo apt update && sudo apt install python3-pip -y
    

    Alternatively, you can build from source:

    git clone https://github.com/python-telegram-bot/python-telegram-bot
    
    python setup.py install
    
    git submodule update --init --recursive
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search