cqlsh is broken on new installs of Cassandra 2.2 and 3.0

There’s nothing fun about installing some software for the first time and feeling like it doesn’t work at all. Unfortunately if you’ve just installed Cassandra 2.2 or 3.0 on a recent Linux distribution, you may run into a not-so-friendly Connection error when trying to use cqlsh:

Connection error: ('Unable to connect to any servers', {'127.0.0.1': TypeError('ref() does not take keyword arguments',)})

If you’ve come to this post hoping for a fix, the simple solution is to install the latest Python Cassandra driver and tell cqlsh to use it instead of the bundled one:

pip install cassandra-driver  
export CQLSH_NO_BUNDLED=true

Why would this be necessary? The answer is subtle. After reading through CASSANDRA-11850, it starts to become clear. It turns out this is due to a change in the behavior of the weakref.ref() function in Python 2.7.12 changelog.

This is one of those cases where fixing one bug introduces potentially dozens of new ones.

cassandra python drivers cqlsh