Unable to run cqlsh due to python attribute error

1.3k Views Asked by At

Unable to execute the command cqlsh in mac m1 based system.

% bin/cqlsh
Traceback (most recent call last):
  File "/Users/avinashkasukurthi/devtools/apache-cassandra-4.0.7/bin/cqlsh.py", line 159, in <module>
    from cqlshlib import cql3handling, cqlhandling, pylexotron, sslhandling, cqlshhandling
  File "/Users/avinashkasukurthi/devtools/apache-cassandra-4.0.7/bin/../pylib/cqlshlib/cql3handling.py", line 19, in <module>
    from cqlshlib.cqlhandling import CqlParsingRuleSet, Hint
  File "/Users/avinashkasukurthi/devtools/apache-cassandra-4.0.7/bin/../pylib/cqlshlib/cqlhandling.py", line 23, in <module>
    from cqlshlib import pylexotron, util
  File "/Users/avinashkasukurthi/devtools/apache-cassandra-4.0.7/bin/../pylib/cqlshlib/pylexotron.py", line 342, in <module>
    class ParsingRuleSet:
  File "/Users/avinashkasukurthi/devtools/apache-cassandra-4.0.7/bin/../pylib/cqlshlib/pylexotron.py", line 343, in ParsingRuleSet
    RuleSpecScanner = SaferScanner([
                      ^^^^^^^^^^^^^^
  File "/Users/avinashkasukurthi/devtools/apache-cassandra-4.0.7/bin/../pylib/cqlshlib/saferscanner.py", line 91, in __init__
    s = re.sre_parse.State()
        ^^^^^^^^^^^^
AttributeError: module 're' has no attribute 'sre_parse'
2

There are 2 best solutions below

1
On

Looks like there may have been a breaking change introduced to Python's synchronized regex engine (SRE) with Python 3.11. I have created a ticket for this on the Cassandra project (CASSANDRA-18088).

In the interim, downgrade your local Python to 3.10, and you should be fine.

0
On

In case you have both python 3.11 and 3.10 installed on your machine, you dont need to uninstall any version.

The cqlsh has the option to pass the python interpreter version as parameter.

you can run it as:-

./cqlsh --python /usr/local/bin/python3.10

on the terminal.