R
R
Roman Romanov2019-08-04 12:08:55
Python
Roman Romanov, 2019-08-04 12:08:55

How to fix 'set' object has no attribute 'get' error in telegram bot?

Hello, I am writing a Python telegram bot using the telebot library

import telebot
from telebot import apihelper

bot = telebot.TeleBot("Мой_токен")
apihelper.proxy = {"https':'https://88.204.154.155:8080"}

@bot.message_handler(commands=['start', 'help'])
def send_welcome(message):
  bot.reply_to(message, "Howdy, how are you doing?")

@bot.message_handler(func=lambda message: True)
def echo_all(message):
  bot.reply_to(message, message.text)

bot.polling()

gives the following error:
2019-08-04 11:58:01,333 (util.py:65 PollingThread) ERROR - TeleBot: "AttributeError occurred, args=("'set' object has no attribute 'get'",)
Traceback (most recent call last):
  File "C:\python\dsi\venv\lib\site-packages\telebot\util.py", line 59, in run
    task(*args, **kwargs)
  File "C:\python\dsi\venv\lib\site-packages\telebot\__init__.py", line 276, in __retrieve_updates
    updates = self.get_updates(offset=(self.last_update_id + 1), timeout=timeout)
  File "C:\python\dsi\venv\lib\site-packages\telebot\__init__.py", line 246, in get_updates
    json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates)
  File "C:\python\dsi\venv\lib\site-packages\telebot\apihelper.py", line 180, in get_updates
    return _make_request(token, method_url, params=payload)
  File "C:\python\dsi\venv\lib\site-packages\telebot\apihelper.py", line 54, in _make_request
    timeout=(connect_timeout, read_timeout), proxies=proxy)
  File "C:\python\dsi\venv\lib\site-packages\requests\sessions.py", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\python\dsi\venv\lib\site-packages\requests\sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "C:\python\dsi\venv\lib\site-packages\requests\adapters.py", line 337, in send
    conn = self.get_connection(request.url, proxies)
  File "C:\python\dsi\venv\lib\site-packages\requests\adapters.py", line 241, in get_connection
    proxy = proxies.get(urlparse(url.lower()).scheme)
AttributeError: 'set' object has no attribute 'get'
"
Traceback (most recent call last):
  File "C:/python/dsi/venv/telegram.py", line 15, in <module>
    bot.polling()
  File "C:\python\dsi\venv\lib\site-packages\telebot\__init__.py", line 389, in polling
    self.__threaded_polling(none_stop, interval, timeout)
  File "C:\python\dsi\venv\lib\site-packages\telebot\__init__.py", line 412, in __threaded_polling
    polling_thread.raise_exceptions()
  File "C:\python\dsi\venv\lib\site-packages\telebot\util.py", line 78, in raise_exceptions
    six.reraise(self.exc_info[0], self.exc_info[1], self.exc_info[2])
  File "C:\python\dsi\venv\lib\site-packages\six.py", line 693, in reraise
    raise value
  File "C:\python\dsi\venv\lib\site-packages\telebot\util.py", line 59, in run
    task(*args, **kwargs)
  File "C:\python\dsi\venv\lib\site-packages\telebot\__init__.py", line 276, in __retrieve_updates
    updates = self.get_updates(offset=(self.last_update_id + 1), timeout=timeout)
  File "C:\python\dsi\venv\lib\site-packages\telebot\__init__.py", line 246, in get_updates
    json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates)
  File "C:\python\dsi\venv\lib\site-packages\telebot\apihelper.py", line 180, in get_updates
    return _make_request(token, method_url, params=payload)
  File "C:\python\dsi\venv\lib\site-packages\telebot\apihelper.py", line 54, in _make_request
    timeout=(connect_timeout, read_timeout), proxies=proxy)
  File "C:\python\dsi\venv\lib\site-packages\requests\sessions.py", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\python\dsi\venv\lib\site-packages\requests\sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "C:\python\dsi\venv\lib\site-packages\requests\adapters.py", line 337, in send
    conn = self.get_connection(request.url, proxies)
  File "C:\python\dsi\venv\lib\site-packages\requests\adapters.py", line 241, in get_connection
    proxy = proxies.get(urlparse(url.lower()).scheme)
AttributeError: 'set' object has no attribute 'get'

Google did not give any results, the manual does not say anything about a similar error.
How to fix it?
apihelper is also installed

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Yakushenko, 2019-08-04
@avelecter

apihelper.proxy = {'http': 'http://88.204.154.155:8080'}

How did you come up with the idea of ​​putting opening quotes "and closing quotes '?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question