K
K
kekovkek2019-11-28 23:50:07
Python
kekovkek, 2019-11-28 23:50:07

PyTelegramBotApi: AttributeError occurred, args=("'NoneType' object has no attribute 'format'",), what's the problem?

Friends, save!
Trying to write my first bot using pyTelegramBotApi:

import telebot
bot = telebot.TeleBot(TOKEN);
bot.polling()

Using a proxy:
from telebot import apihelper
apihelper.proxy = {'https': 'socks5://154.221.21.197:10800'}

Or without it (through the system OpenVPN) gives the same error:
2019-11-28 00:44:10,836 (util.py:66 PollingThread) ERROR - TeleBot: "AttributeError occurred, args=("'NoneType' object has no attribute 'format'",)
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\util.py", line 60, in run
    task(*args, **kwargs)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\__init__.py", line 278, in __retrieve_updates
    updates = self.get_updates(offset=(self.last_update_id + 1), timeout=timeout)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\__init__.py", line 248, in get_updates
    json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\apihelper.py", line 189, in get_updates
    return _make_request(token, method_url, params=payload)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\apihelper.py", line 49, in _make_request
    request_url = base_url.format(token, method_name)
AttributeError: 'NoneType' object has no attribute 'format'
"
Traceback (most recent call last):
  File "C:/Users/user/PycharmProjects/bot/newbot.py", line 14, in <module>
    bot.polling()
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\__init__.py", line 391, in polling
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\__init__.py", line 414, in __threaded_polling
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\util.py", line 79, in raise_exceptions
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\six-1.13.0-py3.7.egg\six.py", line 696, in reraise
    raise value
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\util.py", line 60, in run
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\__init__.py", line 278, in __retrieve_updates
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\__init__.py", line 248, in get_updates
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\apihelper.py", line 189, in get_updates
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\apihelper.py", line 49, in _make_request
AttributeError: 'NoneType' object has no attribute 'format'

Process finished with exit code 1

What could it be? The problem with the proxy seems to be brushed aside, but I don’t see any other errors in the code.
Installed gunicorn, PySocks, pyTelegramBotAPI, requests, urllib3 latest versions following advice from the internet.
IDE: PyCharm 3.0.3
Python 3.7.4
Thanks!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
arynyklas, 2019-11-29
@arynyklas

pip install telebot
and all)
PS write

TOKEN = "ваш токен" # например - XXXXXXXXX:XXXXXXXXXXXXXXXXXXXX-XXXXXXXXXXXX

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question