Datastax cassandra-driver(python)导入失败

时间:2022-08-29 04:47:04

When importing datastax cassandra-driver(python) get the following error

导入数据时cassandra-driver(python)会出现以下错误

Error

错误

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

This is the code

这是代码

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

2 个解决方案

#1


11  

Well, it looks like names conflict. Your script is cassandra.py and so it is the module for the driver. Try to rename your script (and don't forget to delete its .pyc) and try again

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

#2


1  

Install CQL interactive terminal:

安装CQL交互式终端:

sudo pip install cqlsh

#1


11  

Well, it looks like names conflict. Your script is cassandra.py and so it is the module for the driver. Try to rename your script (and don't forget to delete its .pyc) and try again

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

#2


1  

Install CQL interactive terminal:

安装CQL交互式终端:

sudo pip install cqlsh