Search code examples
python-3.xtelegram-botpython-telegram-bot

python-telegram-bot doesn't work on Python 3.x


I'm trying to make a program that uses python-telegram-bot, and I need to use Python 3 for that. But when I try to launch it using Python 3, I get some error I don't quite understand. The same happens when I use the built-in examples. Could somebody explain what it means? The precise output of the program follows.

2016-06-29 06:17:44,260 - telegram.ext.updater - ERROR - unhandled exception

Traceback (most recent call last):

  File "/usr/local/lib/python3.4/dist-packages/telegram/ext/updater.py", line 105, in _thread_wrapper

    target(*args, **kwargs)

  File "/usr/local/lib/python3.4/dist-packages/telegram/ext/updater.py", line 216, in _start_polling

    self._bootstrap(bootstrap_retries, clean=clean, webhook_url='')

  File "/usr/local/lib/python3.4/dist-packages/telegram/ext/updater.py", line 320, in _bootstrap

    self.bot.setWebhook(webhook_url=webhook_url, certificate=cert)

  File "/usr/local/lib/python3.4/dist-packages/telegram/bot.py", line 121, in decorator

    result = func(self, *args, **kwargs)

   File "/usr/local/lib/python3.4/dist-packages/telegram/bot.py", line 1263, in setWebhook

    result = request.post(url, data, timeout=kwargs.get('timeout'))

  File "/usr/local/lib/python3.4/dist-packages/telegram/utils/request.py", line 174, in post

    headers={'Content-Type': 'application/json'})

  File "/usr/local/lib/python3.4/dist-packages/telegram/utils/request.py", line 100, in _request_wrapper

    resp = _get_con_pool().request(*args, **kwargs)

  File "/usr/lib/python3/dist-packages/urllib3/request.py", line 72, in request

    **urlopen_kw)

  File "/usr/lib/python3/dist-packages/urllib3/request.py", line 135, in request_encode_body

    **urlopen_kw)

TypeError: urlopen() got multiple values for keyword argument 'body'

Exception in thread updater:

Traceback (most recent call last):

  File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner

    self.run()

  File "/usr/lib/python3.4/threading.py", line 868, in run

     self._target(*self._args, **self._kwargs)

  File "/usr/local/lib/python3.4/dist-packages/telegram/ext/updater.py", line 105, in _thread_wrapper

    target(*args, **kwargs)

  File "/usr/local/lib/python3.4/dist-packages/telegram/ext/updater.py", line 216, in _start_polling

    self._bootstrap(bootstrap_retries, clean=clean, webhook_url='')

  File "/usr/local/lib/python3.4/dist-packages/telegram/ext/updater.py", line 320, in _bootstrap

    self.bot.setWebhook(webhook_url=webhook_url, certificate=cert)

  File "/usr/local/lib/python3.4/dist-packages/telegram/bot.py", line 121, in decorator

    result = func(self, *args, **kwargs)

  File "/usr/local/lib/python3.4/dist-packages/telegram/bot.py", line 1263, in setWebhook

    result = request.post(url, data, timeout=kwargs.get('timeout'))

  File "/usr/local/lib/python3.4/dist-packages/telegram/utils/request.py", line 174, in post

    headers={'Content-Type': 'application/json'})

  File "/usr/local/lib/python3.4/dist-packages/telegram/utils/request.py", line 100, in _request_wrapper

    resp = _get_con_pool().request(*args, **kwargs)

  File "/usr/lib/python3/dist-packages/urllib3/request.py", line 72, in request

    **urlopen_kw)

  File "/usr/lib/python3/dist-packages/urllib3/request.py", line 135, in request_encode_body

    **urlopen_kw)

TypeError: urlopen() got multiple values for keyword argument 'body'

2016-06-29 06:17:45,248 - telegram.ext.dispatcher - CRITICAL - stopping due to exception in another thread

Solution

  • For this to work, install urllib3>=1.10 from the package manager.