Search code examples
pythongitpython-2.7telegram-botpython-telegram-bot

Although I install python-telegram-bot, error of no module named 'telegram'


I installed telegram packages. But when I try to run the simple example, echobot.py, I got an error:

Traceback (most recent call last):
    File "echobot.py", line 8, in <module>
import telegram ImportError: No module named 'telegram'

Can anyone help me?

I install using git:

$ git clone https://github.com/python-telegram-bot/python-telegram-bot

after this:

$ python -i
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

import telegram

Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
ImportError: No module named 'telegram'

Solution

  • You are not installing it. You are just downloading it.
    Run these:

    cd python-telegram-bot
    python setup.py install
    

    (stated in readme of the GitHub page)

    Alternatively, you can use pip. It's easier to use.

    pip install python-telegram-bot