Question

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

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
Was it helpful?

Solution

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

OTHER TIPS

Install CQL interactive terminal:

sudo pip install cqlsh

I tried this and it worked in my case: python -m pip install `

for example: python -m pip install cassandra-driver

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top