6

I have installed Python 3.6 or 3.7 with Cassandra 3.11.3.
But it does not supporte cqlsh, it only supports the Python 2.7 version.
This is the error message:

\apache-cassandra-3.11.3\bin\\cqlsh.py", line 146  
    except ImportError, e:  
                      ^  
SyntaxError: invalid syntax  

What may be the problem?

Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153

4 Answers4

1

Cqlsh is written in Py2.7, so it'll not build on py3 wrapper env. Even if you change the exception line, it'll not compile the. For example, take this line:

File "/home/usr/.local/bin/cqlsh", line 212
    print '\nWarning: Specified cqlshrc location `%s` does not exist.  Using `%s` instead.\n' % (CONFIG_FILE, HISTORY_DIR)
                                                                                            ^
SyntaxError: invalid syntax

Optional solutions:

  • Downgrade your python version using sudo-alternatives (check versions with update-alternatives --list python)
  • Correct the entire file (not viable)
  • Connect throug datastax or similar driver and query.
0

Change

except a, b:

to

except a as b:

Add parens to prints

brian beuning
  • 2,836
  • 18
  • 22
0

Change: except ImportError, e: To: except ImportError as ex: or
except ImportError:

skomlev
  • 27
  • 3
0

If you have the both version, set the Python2.7 as the main one. You can check the principal version using the command python -V. Then change using this command sudo ln -sf /usr/bin/python3.6 /usr/bin/python (use your path python 3x and 2x). Check if it was ok using python -V. Call the $cqlsh again.

Ps.: If necessary check the cqlsh file, if the header is correct. If it is #!/usr/bin/python3 fix to #!/usr/bin/python. You can use $find / -name cqlshto find the files.

Luciana Oliveira
  • 822
  • 4
  • 14
  • 35