Python-telegram-bot: TypeError: urlopen() got multiple values for keyword argument 'body'

Created on 11 Dec 2016  路  4Comments  路  Source: python-telegram-bot/python-telegram-bot

Steps to reproduce

  1. save example from https://python-telegram-bot.org/ into file bot.py
  2. change token
  3. run pyhon bot.py

Expected behaviour

send message to bot

Actual behaviour

it crash

file bot.py

cat bot.py

from telegram.ext import Updater, CommandHandler

def start(bot, update):
    update.message.reply_text('Hello World!')

def hello(bot, update):
    update.message.reply_text(
        'Hello {}'.format(update.message.from_user.first_name))

updater = Updater('MY_TOKEN')

updater.dispatcher.add_handler(CommandHandler('start', start))
updater.dispatcher.add_handler(CommandHandler('hello', hello))

updater.start_polling()
updater.idle()

Configuration

Debian 8.6

Version of Python, python-telegram-bot & dependencies:

```python-telegram-bot 5.2.0
urllib3 1.9.1
certifi 2016.09.26
future 0.16.0
Python 2.7.9 (default, Jun 29 2016, 13:08:31) [GCC 4.9.2]

### Logs

python bot.py
Exception in thread updater:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(self.__args, *self.__kwargs)
File "/usr/local/lib/python2.7/dist-packages/telegram/ext/updater.py", line 115, in _thread_wrapper
target(args, *kwargs)
File "/usr/local/lib/python2.7/dist-packages/telegram/ext/updater.py", line 228, in _start_polling
self._bootstrap(bootstrap_retries, clean=clean, webhook_url='')
File "/usr/local/lib/python2.7/dist-packages/telegram/ext/updater.py", line 335, in _bootstrap
self.bot.setWebhook(webhook_url=webhook_url, certificate=cert)
File "/usr/local/lib/python2.7/dist-packages/telegram/bot.py", line 124, in decorator
result = func(self, args, *kwargs)
File "/usr/local/lib/python2.7/dist-packages/telegram/bot.py", line 1272, in setWebhook
result = self._request.post(url, data, timeout=timeout)
File "/usr/local/lib/python2.7/dist-packages/telegram/utils/request.py", line 205, in post
*urlopen_kwargs)
File "/usr/local/lib/python2.7/dist-packages/telegram/utils/request.py", line 132, in _request_wrapper
resp = self._con_pool.request(
args, *kwargs)
File "/usr/lib/python2.7/dist-packages/urllib3/request.py", line 72, in request
*
urlopen_kw)
File "/usr/lib/python2.7/dist-packages/urllib3/request.py", line 135, in request_encode_body
**urlopen_kw)
TypeError: urlopen() got multiple values for keyword argument 'body'

```

Most helpful comment

upgraded to 1.16-1~bpo8+1 with aptitude -V install python-urllib3/jessie-backports

All 4 comments

@rchovan Try installing python-telegram-bot in a virtualenv. This error is usually caused by an old version of urllib3 that is installed by your systems package manager and cannot be replaced with a newer version by pip.

@jh0ker which version of urllib3 do I need ? Currently I have this:
```aptitude show python-urllib3
aptitude show python-urllib3
Package: python-urllib3
New: yes
State: installed
Automatically installed: yes
Version: 1.9.1-3
Priority: optional
Section: python
Maintainer: Debian Python Modules Team python-modules-team@lists.alioth.debian.org
Architecture: all
Uncompressed Size: 245 k
Depends: python:any (< 2.8), python:any (>= 2.7.5-5~), python-six
Recommends: ca-certificates, python-ndg-httpsclient, python-openssl, python-pyasn1
Description: HTTP library with thread-safe connection pooling for Python
urllib3 supports features left out of urllib and urllib2 libraries.

  • Re-use the same socket connection for multiple requests (HTTPConnectionPool and HTTPSConnectionPool) (with optional client-side certificate verification).
  • File posting (encode_multipart_formdata).
  • Built-in redirection and retries (optional).
  • Supports gzip and deflate decoding.
  • Thread-safe and sanity-safe.
  • Small and easy to understand codebase perfect for extending and building upon.
    Homepage: http://urllib3.readthedocs.org
    ```

@rchovan urllib3 must be at least 1.10

upgraded to 1.16-1~bpo8+1 with aptitude -V install python-urllib3/jessie-backports

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rspadim picture rspadim  路  5Comments

kmahsi picture kmahsi  路  4Comments

s-chizhik picture s-chizhik  路  4Comments

marekyggdrasil picture marekyggdrasil  路  5Comments

mzsalam picture mzsalam  路  5Comments