ModuleNotFoundError: No module named 'telegram.utils'

Question:

I have installed python-telegram-bot like:

pip install python-telegram-bot

When I’m try to do this:

from telegram.ext import Updater, CommandHandler, MessageHandler, filters
from telegram.utils.helpers import escape_markdown

I get this error:

ModuleNotFoundError: No module named 'telegram.utils'
Asked By: Jakeer

||

Answers:

See telegram sourcecode:

The function escape_markdown is located in telegram/helpers.py, so the correct import should be next:

root@shdebian1:~# python3
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from telegram.helpers import escape_markdown
Answered By: atline
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.