After running pip install python-telegram-bot
, I’m getting this error that the ‘telegram’ module is not found.
Under pip list
I see that my python-telegram-bot package is installed version 13.2
Is anyone else getting this error?
asked Feb 17, 2021 at 6:41
2
Try another way to install it
first remove it
pip3 uninstall python-telegram-bot
Clone and install
git clone https://github.com/python-telegram-bot/python-telegram-bot
cd python-telegram-bot
python3 setup.py install
pip3 install python-telegram-bot
It should work
answered Dec 14, 2021 at 23:43
Paulo VictorPaulo Victor
3,7142 gold badges25 silver badges29 bronze badges
I also had this problem — for me the issue was that I was trying to run my code from a module called telegram.py
. Newbie mistake I know…
answered Feb 28, 2022 at 21:29
JossyJossy
5212 gold badges12 silver badges35 bronze badges
pip3 install python-telegram-bot
Install it in outside of virutal environment in terminal. Also unintall telegram
. python-telegram-bot
is sufficient for Telegram bot. In my case it resolved my issue.
answered May 11, 2022 at 2:58
Do 1-2 via terminal and 4 on your IDE:
Install pip install telegram Install pip install python-telegram-bot
If you are using a virtual environment, make sure it is activated
Lastly, **import from telegram.ext import ***
answered Jan 9 at 22:16
EnzoEnzo
115 bronze badges
I had the same problem, this is how I solved it:
Open Windows PowerShell and run it as an administrator. > Run the following Command » Get-ExecutionPolicy» If it is set to restricted change it to allow remote sign using the following command «Set-ExecutionPolicy RemoteSigned» > Now open your terminal and run «pip install python-telegram-bot» to install the bot afresh.
Problem solved.
answered 1 hour ago
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'
phd
80.4k12 gold badges115 silver badges156 bronze badges
asked Jul 28, 2017 at 21:30
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
answered Jul 28, 2017 at 21:34
cagricagri
8078 silver badges16 bronze badges
4
For my case, I solved it this way.
pip install telegram
answered Feb 2, 2021 at 19:04
I noticed when I import telegram.ext, it does not find .ext. The issue was caused by telegram and python-telegram modules being installed. Delete these and install only python-telegram-bot. It should work.
answered Feb 19, 2022 at 16:21
Try to uninstall it by pip uninstall python-telegram-bot
And after that install it again pip install python-telegram-bot
SwissCodeMen
4,0856 gold badges23 silver badges33 bronze badges
answered Jan 25 at 17:57
Thre problem is in line with smth like
sys.path.append(os.path.join(os.path.abspath('.'), 'lib'))
in bot_gae.py.
You have to point at REAL place, where you’ve installed python-telegram-bot.
In my case it’s ./lib in project directory.
wscourge
10.4k14 gold badges57 silver badges79 bronze badges
answered Oct 18, 2017 at 9:48
If you have named your python file as telegram.py then it will throw this error because the program is calling ext function from the file itself.
Try renaming your python file to something else it will work.
answered Oct 29, 2022 at 14:45
In my case, I had two python versions installed.
A quick solution is to idetify which python your code is using. Then go to bin directory where the python is installed. Find the pip binary name inside that using command
ls -lrt | grep pip
In my cases the name was pip3.6. So use then use that pip name and execute from same directory
pip3.6 install python-telegram-bot
Long term fix is to add your pip3.6 shortcut in /usr/bin or /usr/loca/bin and install packages using pip3.6 command
answered Dec 15, 2022 at 3:50
Ganesh SGanesh S
3736 silver badges25 bronze badges
Install
pip install django-telegrambot
Configure your installation
settings.py
INSTALLED_APPS = (
…
‘django_telegrambot’,
)
answered Jun 14, 2020 at 6:18
1
Hi everyone, I was trying to test echobot2.py example and couldn’t make it work. This same error every time:
Traceback (most recent call last):
File «C:/Users/Vitor/PycharmProjects/untitled1/new.py», line 18, in
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
ModuleNotFoundError: No module named ‘telegram.ext’
Process finished with exit code 1
I tried all the things you guys suggested but didn’t get it working. Some help?
Hi. Have you successfully installed python-telegram-bot via pip(3)? If yes, what’s the output of $ python -m telegram
, i.e. which version are you running?
Hi. Have you successfully installed python-telegram-bot via pip(3)? If yes, what’s the output of
$ python -m telegram
, i.e. which version are you running?
There it is
C:UsersVitor>python -m pip install —upgrade pip
Collecting pip
Using cached https://files.pythonhosted.org/packages/00/b6/9cfa56b4081ad13874b0c6f96af8ce16cfbc1cb06bedf8e9164ce5551ec1/pip-19.3.1-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 19.2.3
Uninstalling pip-19.2.3:
Successfully uninstalled pip-19.2.3
Successfully installed pip-19.3.1
C:UsersVitor>python -m pip install —upgrade pip
Requirement already up-to-date: pip in c:usersvitoranaconda3libsite-packages (19.3.1)
C:UsersVitor>python -m telegram
C:UsersVitorAnaconda3python.exe: No module named telegram
C:UsersVitor>
C:UsersVitor>python -m pip install --upgrade pip ... Successfully installed pip-19.3.1
This just installs pip, not python-telegram-bot
C:UsersVitor>python -m telegram C:UsersVitorAnaconda3python.exe: No module named telegram
Hence this output.
But on your second image the command line stets that ptb is indeed installed. So did you run pip(3) install python-telegram-bot
?
C:UsersVitorAnaconda3python.exe: No module named telegram
Also I see that you’re using Anaconda. I’m not actually familiar with that, but if I understand this correctly, it needs special tretment. Try
conda install python-telegram-bot
and see here for details.
@Bibo-Joshi I think the problem is pycharm created an env for the project, and the library is installed globaly, not in the env for the project.
Thanks you all, i don’t know what i did, but it is working now. I think it was something @Bibo-Joshi sad. I uninstall all and re install all.
hey! i have this problem too,
Traceback (most recent call last):
File «C:/Users/Bartar/PycharmProjects/Training/venv/p1.py», line 1, in
from telegram.txt import Updater
ModuleNotFoundError: No module named ‘telegram.txt’
(venv) C:UsersBartarPycharmProjectsTraining>python -m telegram
python-telegram-bot 12.8
certifi 2020.06.20
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:20:19) [MSC v.1925 32 bit (Intel)]
what can i do?
How are you starting this script?
I wrote telegram.txt and now write with .ext
And its worke
Is it deprected? (telegram.ext)
no its not you just made a typo I didnt see
I’ve been having problems with this since yesterday.
I Finally fixed it by making sure to run the install using pip3 instead of pip (as mentioned above by @Bibo-Joshi .
pip3 install python-telegram-bot
All running smoothly now on Raspberry Pi 3 + Latest Raspbian (as of 2020/06/27)
Thanks to all
Thank you all.. I had the same problem and pip3 install python-telegram-bot solved my problem
github-actions
bot
locked as resolved and limited conversation to collaborators
Aug 17, 2020
при запуске кода:
from telegram.ext import Updater
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
updater = Updater(token='677329060:AAGhtwMc9fYoaNvnUs7est0vXcwf6FGkWk4')
dispatcher = updater.dispatcher
def startCommand(bot, update):
bot.send_message(chat_id=update.message.chat_id, text='Привет, давай пообщаемся?')
def textMessage(bot, update):
response = 'Получил Ваше сообщение: ' + update.message.text
bot.send_message(chat_id=update.message.chat_id, text=response)
start_command_handler = CommandHandler('start', startCommand)
text_message_handler = MessageHandler(Filters.text, textMessage)
dispatcher.add_handler(start_command_handler)
dispatcher.add_handler(text_message_handler)
updater.start_polling(clean=True)
updater.idle()
updater.idle()
программа нет выдает:
Traceback (most recent call last):
File "/Users/sergey/PycharmProjects/chat/bot.py", line 1, in <module>
from telegram.ext import Updater
ModuleNotFoundError: No module named 'telegram'
у меня Python3.7 работаю в PyCharmCommunity
pip install python-telegram-bot сделал
Всем привет. Столкнулся со следующей проблемой: при импорте модуля telegram (python-telegram-bot) выскакивает ошибка в трейсбеке «module ‘telegram’ has no attribute ‘Bot'». Причем ошибка при тесте обычного кода из документации.
import telegram
bot = telegram.Bot(token='TOKEN')
print(bot.get_me())
Сам модуль несколько раз удалял и заново ставил в терминале. Подскажите в чем может быть причина?
-
Вопрос заданболее года назад
-
3657 просмотров
Пригласить эксперта
Убедись что у тебя больше не установлены пакеты которые могут импортироваться вместо этой библиотеки
pip3 list | grep -i telegram
Если есть, то удали их и переустанови библиотеку снова
pip3 install --user --force-reinstall python-telegram-bot
есть вероятность вы не ту установили(«pip install python-telegram-bot» вы же сделали?)
Попробуй через апдейтер
from telegram.ext import Updater
updater = Updater(token='<YOUR TOKEN HERE>')
dispatcher = updater.dispatcher
def startCommand(bot, update):
bot.send_message(chat_id=update.message.chat_id, text='Hello!')
start_command_handler = CommandHandler('start', startCommand)
updater.start_polling(clean=True)
updater.idle()
Не знаю, поможет или нет, но выкрутился так
-
Показать ещё
Загружается…
29 мая 2023, в 13:30
30000 руб./за проект
29 мая 2023, в 13:26
5000 руб./за проект
29 мая 2023, в 13:25
130000 руб./за проект