1

Well, I've tried to run another's person telegram bot on my computer, but got a mistake that:

Traceback (most recent call last):
  File "C:\Users\Dmitriy\PycharmProjects\pythonProject\Main.py", line 10, in <module>
    keyboard = telebot.types.ReplyKeyboardMarkup(True, True)
AttributeError: module 'telebot' has no attribute 'types'

I've tried to import types from telebot:

from telebot import types

But it didn't actually helped. The strangest thing is that this code works on code owner's computer.

What can this be about?

enter image description here

dim0ntei
  • 39
  • 1
  • 8

4 Answers4

3

The problem is that telebot and pyTelegramBotApi are different libraries but they are both imported via import telebot. In fact, when you do from telebot import types you import it from pyTelegramBotApi, not from telebot.

To fix the issue just type:

pip uninstall telebot
pip uninstall pyTelegramBotApi
pip install pyTelegramBotApi

It worked for me :)

1

You need to install python-telegram-bot f.e via pip

pip install python-telegram-bot 

then import it from telegram package

from telegram import ReplyKeyboardMarkup

and replace creation of ReplyKeyboardMarkup into this:

keyboard = ReplyKeyboardMarkup(True, True)
domandinho
  • 1,260
  • 2
  • 16
  • 29
  • @domandihno , that didn't actually helped( – dim0ntei Jul 25 '21 at 14:07
  • what error do you have after application of that chagne? Error should be different as in solution i've proposed we don't import ReplyKeyboardMarkup from telebot.types – domandinho Jul 25 '21 at 14:21
0

for like these errors ... reinstall the library or use (--upgrade) when you install it !

like this:

pip uninstall telebot
pip install pyTelegramBotAPI
pip install pytelegrambotapi --upgrade

Happy Coding!

sMx_7d
  • 37
  • 6
0

If you use PyCharm, then I advise you to do the following.

  1. Go to the directory of your project.
  2. In this directory, open the venv\Scripts directory (eventually you should get the following path \venv\Scripts)
  3. Next, go to the command line along this path AND ONLY AFTER THAT WRITE the pip install pyTelegramBotAPI COMMAND ♥