0

I have a problem with the auto-complete within Cassandra 3.9 client "cqlsh", I don't know why? I did an update my brew command on MacOS Sierra. I suppose this problem is for a python update, but how it's related?

I tried to execute the tests:

$ cd apache-cassandra-3.9/pylib/cqlshlib/test
$ python test_cqlsh_completion.py

but I got this error:

Traceback (most recent call last):
  File "test_cqlsh_completion.py", line 23, in <module>
    from .basecase import BaseTestCase, cqlsh
ValueError: Attempted relative import in non-package

Someone know any solution?

If I list the directory it shows:

$ ls apache-cassandra-3.9/pylib/cqlshlib/test

__init__.py              basecase.py              
run_cqlsh.py             test_cqlsh_commands.py   
test_cqlsh_invocation.py test_cqlsh_parsing.py    
winpty.py                ansi_colors.py           
cassconnect.py           test_cql_parsing.py      
test_cqlsh_completion.py test_cqlsh_output.py     
test_keyspace_init.cql
Anower Perves
  • 754
  • 8
  • 15
christmo
  • 351
  • 2
  • 18

4 Answers4

4

Install pyreadline run this command

pip install pyreadline

pyreadline reference

I run this command on

Windows 7 64 bits

Python 2.7.12

Community
  • 1
  • 1
Harold Castillo
  • 2,006
  • 19
  • 23
  • 1
    Note that after installing readline on MacOSX, you may encountered a wrong version of readline installed. Adding the link solve the problem, see https://stackoverflow.com/a/41560355/540380 – FrankyFred Apr 30 '20 at 16:09
  • 1
    Tested this on Win 10 64 bits - it works well! – Kartik Jun 10 '21 at 17:15
1

you don't have __init__.py in your package folder

Alex
  • 1,141
  • 8
  • 13
  • Yes, I have that file, I read it should be executed with "nose" you know something about this command? – christmo Oct 18 '16 at 19:05
0

I encountered this problem also. Check to see how many python you have.

which -a python

I had 2 Python2s and somehow 2.7.15 was the default binary and cqlsh did not work that well with this version (autocomplete and history did not work).

The fix for me was to put Python 2.7.10 in path before 2.7.15

skipy
  • 4,032
  • 2
  • 23
  • 19
-1

I had a similar issue. The root of the problem was with python's readline package

please, try

python -c 'import readline'

if you get an error, it will guide you to the solution