Import: No module named 'telebot'

Asked

Viewed 1,144 times

1

Hello!

I am configuring the bot to send Zabbix alerts, I have installed Python and the necessary modules:

sudo apt install python python-pip python-setuptools

Then I installed the bot API to use in Zabbix:

python -m pip install --user pyTelegramBotAPI

I created the script in /usr/lib/Zabbix/alertscripts/ :

#!/usr/bin/env python

import telebot,sys

BOT_TOKEN='TOKENAQUI'
DESTINATION=sys.argv[1]
SUBJECT=sys.argv[2]
MESSAGE=sys.argv[3]

MESSAGE = MESSAGE.replace('/n','\n')
tb = telebot.TeleBot(BOT_TOKEN)
tb.send_message(DESTINATION,SUBJECT + '\n' + MESSAGE)

I changed the execution permissions:

sudo chmod +x telegram

sudo chown -R zabbix telegram

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

Traceback (Most recent call last): File "/usr/lib/Zabbix/alertscripts/Telegram", line 2, in import telebot,sys Import: No module named 'telebot'

I tried to solve by installing the module:

python -m pip install --user telebot

Installing the module did not solve, then I tried to use python3, so the terminal worked, but in Zabbix keeps showing the same error, I ended up going back to python.

Does anyone know who might be causing the problem?

  • Which version returned with /usr/bin/env python --version and with only python --version?

  • In both is Python 2.7.12

  • Any specific reason you used the --user? Know if the directory is part of your environment variable PATH? You can confirm by checking the path with python -c 'import site; print(site.USER_BASE)' and echo $PATH.

  • The --user I saw in one of the forum I visited while trying to solve, where it said to try using it. The directories of the variable PATH sane /home/appliance/.local and /home/appliance/bin:/home/appliance/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games .

  • I had tried before to install without the option --user? Also gave the error?

  • Yes, I was wrong too, but I can try again

  • Hasn’t changed, keeps making the same mistake.

  • The module telebot appears with pip list? Or when, inside the python terminal, you give the command help("modules")?

  • It only appears inside the Python terminal

Show 4 more comments

1 answer

0


I managed to solve, using the python3, but this time I removed the other versions of python completely before installing again, the steps were as follows:

sudo python -m pip uninstall pyTelegramBotAPI
sudo apt remove python python-pip python-setuptools
sudo apt install python3 python3-pip python3-setuptools python3-six
sudo python3 -m pip install pyTelegramBotAPI six
sudo pip install six

Browser other questions tagged

You are not signed in. Login or sign up in order to post.