导入数据时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
答案 0 :(得分:16)
好吧,看起来名字冲突了。您的脚本是cassandra.py
,因此它是驱动程序的模块。尝试重命名您的脚本(不要忘记删除其.pyc
)并重试
答案 1 :(得分:1)
安装 CQL交互式终端:
sudo pip install cqlsh
答案 2 :(得分:0)
我尝试了此方法,并且在我的情况下有效: python -m pip install`
例如: python -m pip install cassandra-driver