Skip to main content
 首页 » 编程设计

python之cqlsh::ImportError:无法导入名称 cql_keywords_reserved

2024年10月17日8softidea

最近,我安装了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?

请您参考如下方法:

您看到的是 CASSANDRA-11840 ,使用 Python 2.7.12+ 的旧版本驱动程序会发生这种情况。

要解决这个问题,要么

1.) 升级到Cassandra 3.8+,捆绑了没有这个问题的驱动版本。

或

2.) 让你的环境/路径使用 Python <= 2.7.11

或

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