Datastax Cassandra驱动(Python)导入失败
在导入 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
3 个回答
0
我试过这个方法,在我的情况下有效:
比如说: python -m pip install cassandra-driver
1
安装 CQL 交互式终端:
sudo pip install cqlsh
20
看起来是名字冲突了。你的脚本叫做 cassandra.py
,所以它和驱动程序的模块发生了冲突。试着把你的脚本改个名字(别忘了删除它的 .pyc
文件),然后再试一次。