Datastax cassandra-driver(python)导入失败

jer*_*ues 8 python cassandra 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
Run Code Online (Sandbox Code Playgroud)

这是代码

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
Run Code Online (Sandbox Code Playgroud)

Mik*_*ura 17

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