python-3.xriak

python3 failed to import riak


I used python 3.9.13, and have installed riak client lib. But I failed to

import riak

Here's the exception message below

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/riak/__init__.py", line 9, in <module>
    from riak.client import RiakClient
  File "/usr/local/lib/python3.9/site-packages/riak/client/__init__.py", line 9, in <module>
    from riak.client.operations import RiakClientOperations
  File "/usr/local/lib/python3.9/site-packages/riak/client/operations.py", line 5, in <module>
    from riak.client.transport import RiakClientTransport, \
  File "/usr/local/lib/python3.9/site-packages/riak/client/transport.py", line 3, in <module>
    from riak.transports.tcp import is_retryable as is_tcp_retryable
  File "/usr/local/lib/python3.9/site-packages/riak/transports/tcp/__init__.py", line 5, in <module>
    from riak.transports.tcp.transport import TcpTransport
  File "/usr/local/lib/python3.9/site-packages/riak/transports/tcp/transport.py", line 6, in <module>
    from riak.codecs import Codec, Msg
  File "/usr/local/lib/python3.9/site-packages/riak/codecs/__init__.py", line 9, in <module>
    Msg = collections.namedtuple('Msg',
TypeError: namedtuple() got an unexpected keyword argument 'verbose'

Solution

  • The verbose keyword argument for namedtuple() was deprecated in Python 3.7 and it doesn't look like the package version for riak on PyPi has been updated to account for this.

    It has been patched on the master branch of the riak GitHub repo so you should try pip installing the package directly from GitHub rather from PyPi.

    e.g.

    $ pip install git+https://github.com/basho/riak-python-client