cannot encode objects that are not 2-tuples
Package:
requests
45920

Exception Class:
ValueError
Raise code
"""
:rtype: OrderedDict
"""
if value is None:
return None
if isinstance(value, (str, bytes, bool, int)):
raise ValueError('cannot encode objects that are not 2-tuples')
return OrderedDict(value)
def to_key_val_list(value):
"""Take an object and test to see if it can be represented as a
dictionary. If it can be, return a list of tuples, e.g., """
Links to the raise (2)
https://github.com/psf/requests/blob/f6d43b03fbb9a1e75ed63a9aa15738a8fce99b50/requests/utils.py#L288 https://github.com/psf/requests/blob/f6d43b03fbb9a1e75ed63a9aa15738a8fce99b50/requests/utils.py#L314See also in the other packages (2)
(❌️ No answer)
pipenv/cannot-encode-objects-that-are-no
(❌️ No answer)
pip/cannot-encode-objects-that-are-not-2
Ways to fix
Summary:
Arguments such as params, cookies and data must have values that are dict or can be converted to dicts (e.g a list of 2-tuples)
Reproduce:
import requests
requests.get("http://www.example.com", params="param1") # param cannot be converted to dict
Fix
import requests
requests.get("http://www.example.com", params={'param1':"true"}) # correct value for params
Add a possible fix
Please authorize to post fix