【问题标题】:cqlsh :: ImportError: cannot import name cql_keywords_reservedcqlsh :: ImportError: 无法导入名称 cql_keywords_reserved
【发布时间】:2017-03-28 16:34:09
【问题描述】:

最近安装了Cassandra. 3.6 安装后报错。

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

为了解决这个问题,我关注了

pip install cassandra-driver==2.7.2
pip install cassandra-driver
export CQLSH_NO_BUNDLED=true

而我的python版本是2.7

现在,当我运行 cqlsh 时,出现以下错误

Traceback (most recent call last):
  File "/usr/bin/cqlsh.py", line 167, in <module>
    from cqlshlib import cql3handling, cqlhandling, pylexotron, sslhandling
  File "/usr/lib/python2.7/dist-packages/cqlshlib/cql3handling.py", line 17, in <module>
    from .cqlhandling import CqlParsingRuleSet, Hint
  File "/usr/lib/python2.7/dist-packages/cqlshlib/cqlhandling.py", line 21, in <module>
    from cassandra.metadata import cql_keywords_reserved
ImportError: cannot import name cql_keywords_reserved

我该如何解决这个错误?我怎样才能运行没有错误的 cassandra?

【问题讨论】:

  • pip install cassandra-driver==3.7.1 ?或安装python 2.7.11(或更低)thelastpickle.com/blog/2016/08/16/… 错误是因为3.7中的cqlsh在python驱动程序3分支中使用了api
  • @ChrisLohfink 。我尝试使用 cassandra 驱动程序。还是一样的错误

标签: python cassandra pip cqlsh


【解决方案1】:

您看到的是CASSANDRA-11840,它出现在具有 Python 2.7.12+ 的旧版本驱动程序中。

要解决它,要么

1.) 升级到 Cassandra 3.8+,它捆绑了一个不存在此问题的驱动程序版本。

2.) 让您的环境/PATH 使用 Python

3.) CQLSH_NO_BUNDLED=1 如您所料,但安装具有修复程序的驱动程序版本 (cassandra-driver >= 3.4.0)。

【讨论】:

  • 我遵循了您的第一个选项。我仍然收到另一个错误。
  • Connection error: ('Unable to connect to any servers', {'127.0.0.1': error(111, "Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused")})
  • 这通常表示 Cassandra 没有运行。
  • 你是在问我如何启动 Cassandra?这完全取决于您如何安装它。 here 描述的每个方法都有一个启动服务的步骤。
猜你喜欢
  • 2021-10-11
  • 1970-01-01
  • 2016-03-31
  • 2014-10-10
  • 2014-09-20
  • 2014-08-28
  • 2014-06-10
  • 2016-05-16
  • 2019-05-25
相关资源
最近更新 更多