importerror no module named telebot

I’m configuring a bot to send alerts from Zabbix, so I installed Python and the modules:

After that, I installed the bot API to use on Zabbix:

Created the script in /usr/lib/zabbix/alertscripts/ :

And when testing the script on terminal or Zabbix the following error appears:

Traceback (most recent call last): File «/usr/lib/zabbix/alertscripts/telegram», line 2, in import telebot,sys ImportError: No module named ‘telebot’

I tried to solve by installing the module:

Installing the module did not solve it, so I tried to use python3, and the script on the terminal worked, but in Zabbix still showing the same error. I ended up going back to python.

The telebot module does not appear with pip list , only inside the python terminal using the command help («modules») .

Does anyone know that may be causing the problem?

Пишу код для бота в PyCharm на питоне хочу отправить себе сообщение
bot.send_message(id, «test»)
в id написал свой id диалога с ботом
выдаёт ошибку
C:UsersPublicDocumentsTelebotvenvScriptspython.exe C:/Users/Public/Documents/Telebot/main.py
Traceback (most recent call last):
File «C:/Users/Public/Documents/Telebot/main.py», line 1, in
import telebot
ModuleNotFoundError: No module named ‘telebot’

Process finished with exit code 1
вроде без кирилицы всё

Содержание

  1. Comments
  2. drno-reg commented Mar 28, 2018
  3. This comment has been minimized.
  4. MasterGroosha commented Mar 29, 2018
  5. This comment has been minimized.
  6. drno-reg commented Mar 29, 2018
  7. This comment has been minimized.
  8. MasterGroosha commented Mar 29, 2018
  9. This comment has been minimized.
  10. drno-reg commented Mar 29, 2018
  11. This comment has been minimized.
  12. MasterGroosha commented Mar 29, 2018
  13. This comment has been minimized.
  14. drno-reg commented Mar 30, 2018
  15. This comment has been minimized.
  16. drno-reg commented Mar 30, 2018
  17. This comment has been minimized.
  18. MasterGroosha commented Mar 30, 2018
  19. This comment has been minimized.
  20. drno-reg commented Mar 31, 2018

Comments

Copy link Quote reply

drno-reg commented Mar 28, 2018

Лучше не стало после установки пакета

pip install pytelegrambotapi

c:python36scriptspip install pytelegrambotapi
Requirement already satisfied: pytelegrambotapi in c:python36libsite-packages
Requirement already satisfied: requests in c:python36libsite-packages (from pytelegrambotapi)
Requirement already satisfied: six in c:python36libsite-packages (from pytelegrambotapi)
Requirement already satisfied: urllib3 =1.21.1 in c:python36libsite-packages (from requests->pytelegrambotapi)
Requirement already satisfied: certifi>=2017.4.17 in c:python36libsite-packages (from requests->pytelegrambotapi)
Requirement already satisfied: idna =2.5 in c:python36libsite-packages (from requests->pytelegrambotapi)
Requirement already satisfied: chardet =3.0.2 in c:python36libsite-packages (from requests->pytelegrambotapi)

This comment has been minimized.

Copy link Quote reply

MasterGroosha commented Mar 29, 2018

Во-первых, не нужно открывать новые issue, если речь идёт о старых. В закрытые issue можно комментировать.

Во-вторых, Вы бы всё-таки удосужились прочитать то, что скинули. Питон пишет, что библиотека уже установлена и этот текст НЕ является сообщением об ошибке.

This comment has been minimized.

Copy link Quote reply

drno-reg commented Mar 29, 2018

Думалось не придется так детализировать.
НО придется

взял ваш листинг

import telebot
import config

@bot.message_handler(content_types=[«text»])
def repeat_all_messages(message): # Название функции не играет никакой роли, важно не повторяться
bot.send_message(message.chat.id, message.text)

if name == «main«:
bot.polling(none_stop=True)

установил пакет pip install pytelegrambotapi
он установился успешно

c:python36scriptspip install pytelegrambotapi
Requirement already satisfied: pytelegrambotapi in c:python36libsite-packages
Requirement already satisfied: requests in c:python36libsite-packages (from pytelegrambotapi)
Requirement already satisfied: six in c:python36libsite-packages (from pytelegrambotapi)
Requirement already satisfied: urllib3 =1.21.1 in c:python36libsite-packages (from requests->pytelegrambotapi)
Requirement already satisfied: certifi>=2017.4.17 in c:python36libsite-packages (from requests->pytelegrambotapi)
Requirement already satisfied: idna =2.5 in c:python36libsite-packages (from requests->pytelegrambotapi)
Requirement already satisfied: chardet =3.0.2 in c:python36libsite-packages (from requests->pytelegrambotapi)

запускаю код возвращается ошибка:

Traceback (most recent call last):
File «C:/Server/Repositories/um_open/templates/Test/TelegramBot1.py», line 3, in
import telebot
ModuleNotFoundError: No module named ‘telebot’

Как решить эту проблему?

This comment has been minimized.

Copy link Quote reply

MasterGroosha commented Mar 29, 2018

Вопрос на засыпку: какой интерпретатор Python выполняет Ваш код?

This comment has been minimized.

Copy link Quote reply

drno-reg commented Mar 29, 2018

Python 3.6.5rc1 (v3.6.5rc1:f03c5148cf, Mar 14 2018, 03:12:11) [MSC v.1913 64 bit (AMD64)] on win32

This comment has been minimized.

Copy link Quote reply

MasterGroosha commented Mar 29, 2018

У меня есть большое подозрение, что либо не тот интерпретатор используется, либо остались хвосты от telebot. Проще перезагрузиться и попробовать ещё раз сделать импорт, иногда помогает.

This comment has been minimized.

Copy link Quote reply

drno-reg commented Mar 30, 2018

до прошлого воскресенья у меня было 3 интерпретатора: 2.7, 3.6 и 3.7. Сейчас точно один. Представлю доказательства удаления и новой инсталляции

C:Windowssystem32>pip list
DEPRECATION: The default format will switch to columns in the future. You can use —format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
aiohttp (3.1.1)
async-timeout (2.0.1)
attrs (17.4.0)
certifi (2018.1.18)
chardet (3.0.4)
future (0.16.0)
get (0.0.39)
idna (2.6)
idna-ssl (1.0.1)
multidict (4.1.0)
pip (9.0.3)
post (0.0.26)
public (0.0.65)
query-string (0.0.28)
request (0.0.26)
requests (2.18.4)
setuptools (28.8.0)
six (1.11.0)
telepot (12.6)
urllib3 (1.22)
yarl (1.1.1)

C:Windowssystem32>pip install pytelegrambotapi
Collecting pytelegrambotapi
Using cached pyTelegramBotAPI-3.6.2.tar.gz
Requirement already satisfied: requests in c:python36libsite-packages (from pytelegrambotapi)
Requirement already satisfied: six in c:python36libsite-packages (from pytelegrambotapi)
Requirement already satisfied: chardet =3.0.2 in c:python36libsite-packages (from requests->pytelegrambotapi)
Requirement already satisfied: urllib3 =1.21.1 in c:python36libsite-packages (from requests->pytelegrambotapi)
Requirement already satisfied: certifi>=2017.4.17 in c:python36libsite-packages (from requests->pytelegrambotapi)
Requirement already satisfied: idna =2.5 in c:python36libsite-packages (from requests->pytelegrambotapi)
Installing collected packages: pytelegrambotapi
Running setup.py install for pytelegrambotapi . done
Successfully installed pytelegrambotapi-3.6.2

C:Windowssystem32>pip list
DEPRECATION: The default format will switch to columns in the future. You can use —format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
aiohttp (3.1.1)
async-timeout (2.0.1)
attrs (17.4.0)
certifi (2018.1.18)
chardet (3.0.4)
future (0.16.0)
get (0.0.39)
idna (2.6)
idna-ssl (1.0.1)
multidict (4.1.0)
pip (9.0.3)
post (0.0.26)
public (0.0.65)
pyTelegramBotAPI (3.6.2)
query-string (0.0.28)
request (0.0.26)
requests (2.18.4)
setuptools (28.8.0)
six (1.11.0)
telepot (12.6)
urllib3 (1.22)
yarl (1.1.1)

This comment has been minimized.

Copy link Quote reply

drno-reg commented Mar 30, 2018

в общем не помогло (((

C:ServerRepositoriesum_openvenvScriptspython.exe C:/Server/Repositories/um_open/templates/Test/TelegramBot1.py
Traceback (most recent call last):
File «C:/Server/Repositories/um_open/templates/Test/TelegramBot1.py», line 3, in
import telebot
ModuleNotFoundError: No module named ‘telebot’

This comment has been minimized.

Copy link Quote reply

MasterGroosha commented Mar 30, 2018

Стоп. Вы запускаете скрипт в виртуальном окружении (venv), а библиотеку ставите в глобальное. Либо не используйте venv, либо ставьте библиотеку внутри него

This comment has been minimized.

Copy link Quote reply

drno-reg commented Mar 31, 2018

заработало, досадная ошибка действительно, благодарю за внимание к моим вопросам

Источник: computermaker.info

Техника и Гаджеты
Добавить комментарий