在windows10上用python3运行cassandracqlsh

ryhaxcpt  于 2021-06-13  发布在  Cassandra
关注(0)|答案(2)|浏览(488)

我在试着管理Cassandra cqlsh 在windows10上使用python3命令。
当我运行命令时,出现以下错误:

cqlsh
  File "C:\Program Files\apache-cassandra-3.11.6\bin\\cqlsh.py", line 248
    CONFIG_FILE = os.path.join(HISTORY_DIR, 'cqlshrc')
    ^
SyntaxError: invalid syntax

这就是它在脚本中抱怨的一句话:

if hasattr(options, 'cqlshrc'):
    CONFIG_FILE = options.cqlshrc
    if not os.path.exists(CONFIG_FILE):
        print('\nWarning: Specified cqlshrc location `%s` does not exist.  Using `%s` instead.\n' % (CONFIG_FILE, HISTORY_DIR)
        CONFIG_FILE = os.path.join(HISTORY_DIR, 'cqlshrc')

Cassandra似乎运行得很好,我只是需要一个方法来连接它。
我使用的是python3.8.3,如果可以的话,我不希望降级到2.7。
我怎样才能让它工作?

mmvthczy

mmvthczy1#

发布版本 cqlsh 只支持Python2.7,因此不能在Python3.x上工作。
对python3的支持只会出现在cassandra4中,有望在今年发布。详见Cassandra-15659、Cassandra-10190、Cassandra-15573。

rdrgkggo

rdrgkggo2#

对于这个问题,我有一个更好的解决方法,我有和python3.8相同的问题。我是cql的用户docker。cassandra托管在我的linux机器上,python版本是3.8。我通过docker安装cqlsh,并通过docker连接cassandra

[root@localmonitor ~]# python
Python 3.8.3 (default, Aug 31 2020, 16:03:14)
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
[2]+  Stopped                 /usr/bin/python3
 docker run -it  --rm cassandra cqlsh 192.168.1.117
Connected to Test Cluster at 192.168.1.117:9042.
[cqlsh 5.0.1 | Cassandra 3.11.9 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
cqlsh>

相关问题