11

导入 datastax cassandra-driver(python) 时出现以下错误

错误

File "cassandra.py", line 1, in <module>
    from cassandra.cluster import Cluster
File "/home/vagrant/cassandra.py", line 1, in <module>
    from cassandra.cluster import Cluster
ImportError: No module named cluster

这是代码

from cassandra.cluster import Cluster
print dir(cassandra.cluster)
cluster = Cluster()
session = cluster.connect('userspace')
rows = session.execute('SELECT user_name, gender FROM users')
for user_row in rows:
    print user_row.user_name, user_row.gender
4

3 回答 3

20

嗯,看起来名字有冲突。您的脚本是cassandra.py,因此它是驱动程序的模块。尝试重命名您的脚本(不要忘记删除它.pyc)并重试

于 2014-03-17T18:30:42.610 回答
1

安装CQL 交互终端

sudo pip install cqlsh
于 2016-12-16T09:16:00.830 回答
0

我试过这个,它适用于我的情况: python -m pip install `

例如: python -m pip install cassandra-driver

于 2020-04-25T03:17:01.750 回答