rhgrant10 / berserk

Python client for the lichess API
https://berserk.readthedocs.io
Other
141 stars 36 forks source link

got an unexpected keyword argument 'encoding' #17

Open 9acca9 opened 3 years ago

9acca9 commented 3 years ago

Description

Im using lichs (https://github.com/Cqsi/lichs). On windows works perfect, also on Archlinux. On my raspberry pi with raspbian (after put the token from lichess) i get this, what can i do?:

pi@chess:~/.local/bin $ python3 lichs
Traceback (most recent call last):
  File "lichs", line 10, in <module>
    sys.exit(main())
  File "/home/pi/.local/lib/python3.7/site-packages/lichs/__main__.py", line 34, in main
    account_data = client.account.get()
  File "/home/pi/.local/lib/python3.7/site-packages/berserk/clients.py", line 115, in get
    return self._r.get(path, converter=models.Account.convert)
  File "/home/pi/.local/lib/python3.7/site-packages/berserk/session.py", line 60, in get
    return self.request('GET', *args, **kwargs)
  File "/home/pi/.local/lib/python3.7/site-packages/berserk/session.py", line 56, in request
    return fmt.handle(response, is_stream=is_stream, converter=converter)
  File "/home/pi/.local/lib/python3.7/site-packages/berserk/formats.py", line 35, in handle
    return converter(self.parse(response))
  File "/home/pi/.local/lib/python3.7/site-packages/berserk/formats.py", line 76, in parse
    return response.json(cls=self.decoder)
  File "/usr/lib/python3/dist-packages/requests/models.py", line 889, in json
    self.content.decode(encoding), **kwargs
  File "/usr/lib/python3/dist-packages/simplejson/__init__.py", line 535, in loads
    return cls(encoding=encoding, **kw).decode(s)
TypeError: __init__() got an unexpected keyword argument 'encoding'

Thanks!

EthanLebowitz commented 3 years ago

I get the exact same error, also on raspbian. I get it when running client.users.get_public_data(username)

rwst commented 2 years ago

The reason is this issue with the request package which they are not fixing: https://github.com/psf/requests/issues/4842

One solution would be to deinstall simplejson but here for example jupyter and qt depend on it. Alternatively use Python environments to control what is loaded. This means, however, you cannot use berserk in a jupyter notebook, for example.

Oh this is on OpenSuSE Leap BTW.

rwst commented 2 years ago

BTW these errors can be prevented by catching them from the berserk code, see this: https://github.com/PrefectHQ/prefect/issues/3151 I will submit a patch.