Forums

SyntaxError in telebot/types.py

.

Traceback (most recent call last):
  File "/home/aevseg/telegram_bot/bot.py", line 4, in <module>
    from telebot import *
  .....
  File "/home/aevseg/.local/lib/python2.7/site-packages/telebot/types.py", line 829
    def add(self, *args, row_width=None):
                                                       ^
SyntaxError: invalid syntax

Is there anything I can do about this?

[edit by admin: formatting]

It looks like you've installed a Python 3 library for Python 2; the syntax for variadic arguments changed between those versions.

You should use the pip and python commands that are related to the version of Python that you want to run; for example, use pip3.8 to install a package for Python 3.8, and python3.8 to run it.

That's exactly what I did:

pip2 install telebot Looking in links: /usr/share/pip-wheels Collecting telebot Using cached https://files.pythonhosted.org/packages/65/e0/2494a32a7857638215d2368fce0c6ae342157d3a74c1dcd8b2305f5da372/telebot-0.0.3.tar.gz Collecting requests==2.7.0 Using cached https://files.pythonhosted.org/packages/26/ff/c71b3943bebdd9f7ceb9e137296370587eb0b33fe2eb3732ae168bc45204/requests-2.7.0-py2.py3-none-any.whl Building wheels for collected packages: telebot Building wheel for telebot (setup.py) ... done Created wheel for telebot: filename=telebot-0.0.3-cp27-none-any.whl size=3787 sha256=7b8494532e303195bf9dcecc70a1fd0994fce6a290cafbf3edb8c7f0a99f2a2b Stored in directory: /home/aevseg/.cache/pip/wheels/ba/db/fd/615d8209580a23b26a7de1a154bfcc9a900481f4775fa63539 Successfully built telebot

Everything worked after: pip install PyTelegramBotAPI == 2.2.3 Thank you for your cooperation.

OK, glad to hear you got it working.