Solving Python and cqlsh connection error: ‘ref() does not take keyword arguments’

‘ref() does not take keyword arguments is an error which occurs when Cassandra is not compatible with your version of python.

This post is a guide showing you why you are having this error and how you can get rid of it in the most efficient way possible, I will also include some alternative solutions that may help you.

Exploring the Error : ‘ref() does not take keyword arguments’

The error happens when you are running a python version which is not compatible with Cassandra.

The error is specifically related to Cqlsh breaking with some python versions.

Bellow are the solutions which worked for me and will help you to successfully get rid of the issue.

Solution 1 : Downgrade your Python version

The first solution is simple, whatever the version of python your are using and whatever the version of CASSANDRA you are using. The error you are having should be very similar to this message.

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

The solution is to downgrade your python version to a previous one.

Cqlsh breaks often with new python versions, make sure to downgrade to previous versions.

Follow the link bellow to learn how you can do that.

                                                                       #
https://www.delftstack.com/howto/python/downgrade-python-version/#:~:text=We%20can%20remove%20and%20install,version%20which%20is%20not%20needed.
                                                                       #

The solution above should be enough to solve your issue. If that is not the case, follow the solution bellow.

Solution 2 : edit environment variable

The second solution is to edit the environment variable. You can do that by following the instructions bellow.

First step on windows is to go to the search bar at the bottom and type environment variable then click on the icon that shows up.

After that on the active window you can search for Path and click edit.

Then, paste the following line CQLSH_NO_BUNDLED=TRUE then click save and exit.

This should be enough to make the error disapear.

I hope this guide solved your problem, thank you for reading.

Summing-up

This is the end of our guide, I hope you found at least one solution useful, we try to provide solutions for both Linux and windows users, If you did not solve the issue, I hope you find it online, do not give up, errors are normal in Python, Cheers.

If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/