oldDave
oldDave

Reputation: 405

Cassandra 3.7 with Python, 'NoneType' object has no attribute 'encode_message'

I have a simple python client to fetch data from cassandra. The query string itself runs fine using the DBeaver EE client.

def getDataSet(self, station_id, tablename):
    prepared_stmt = self.session.prepare ( "SELECT event_time, reading FROM " +
                                           tablename + " WHERE station_id = ?;")
    bound_stmt = prepared_stmt.bind([station_id])
    rslt = self.session.execute(bound_stmt)
    df = pd.DataFrame()
    for r in rslt:
        df = df.append(r)
    return df

def __init__(self):
    cluster = Cluster(
        contact_points=['127.0.0.1'],
        )
    self.session = cluster.connect('data')
    self.session.row_factory = tuple_factory
    self.session.client_protocol_handler = NumpyProtocolHandler

I get the following exception

File "/home/david/git/python-example/src/start/fetchcassandra.py", line 13, in getDataSet rslt = self.session.execute(bound_stmt) File "/usr/local/lib/python3.4/dist-packages/cassandra/cluster.py", line 1961, in execute return self.execute_async(query, parameters, trace, custom_payload, timeout, execution_profile).result() File "/usr/local/lib/python3.4/dist-packages/cassandra/cluster.py", line 3649, in result raise self._final_exception cassandra.cluster.NoHostAvailable: ('Unable to complete the operation against any hosts', {<Host: 127.0.0.1 datacenter1>: AttributeError("'NoneType' object has no attribute 'encode_message'",)})

Upvotes: 2

Views: 930

Answers (1)

Adam Holmberg
Adam Holmberg

Reputation: 7375

Most likely the NumpyProtocolHander is not built, so you're assigning None as the protocol handler.

See here for installation notes, and consult your pip log for clues on why it is not being built.

Upvotes: 2

Related Questions