scrapinghub / python-scrapinghub

A client interface for Scrapinghub's API
https://python-scrapinghub.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
202 stars 63 forks source link

`TypeError: __init__() got an unexpected keyword argument 'encoding'` #149

Closed alexander-matsievsky closed 4 years ago

alexander-matsievsky commented 4 years ago

Hi there!

When doing:

pip install scrapinghub[msgpack]

I get the following error:

from os import environ

import msgpack
import scrapinghub as sh

print(
    "",
    f"msgpack.version = {msgpack.version!r}",
    f"sh.__version__ = {sh.__version__!r}",
    "",
    sep="\n",
)

job = sh.ScrapinghubClient(environ.get("SH_APIKEY")).get_job("432787/1/1")
job.items.list(count=1)
SH_APIKEY=... python foobar.py

msgpack.version = (1, 0, 0)
sh.__version__ = '2.3.0'

Traceback (most recent call last):
  File "foobar.py", line 15, in <module>
    job.items.list(count=1)
  File "/home/alexander-matsievsky/.miniconda3/envs/demandmatrix/lib/python3.8/site-packages/scrapinghub/client/proxy.py", line 39, in list
    return list(self.iter(*args, **kwargs))
  File "/home/alexander-matsievsky/.miniconda3/envs/demandmatrix/lib/python3.8/site-packages/scrapinghub/client/proxy.py", line 114, in iter
    for entry in self._origin.iter_values(
  File "/home/alexander-matsievsky/.miniconda3/envs/demandmatrix/lib/python3.8/site-packages/scrapinghub/hubstorage/serialization.py", line 28, in mpdecode
    unpacker = Unpacker(encoding='utf8')
  File "msgpack/_unpacker.pyx", line 317, in msgpack._cmsgpack.Unpacker.__init__
TypeError: __init__() got an unexpected keyword argument 'encoding'
vshlapakov commented 4 years ago

The bug is known and should be fixed by https://github.com/scrapinghub/python-scrapinghub/pull/147, I've just released a new 2.3.1 version with the patch on board. Thanks for the report!