Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Datastax cassandra-driver (python) failed import

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
like image 396
jereques Avatar asked Mar 17 '14 08:03

jereques


2 Answers

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

like image 75
Mikhail Stepura Avatar answered Oct 05 '22 02:10

Mikhail Stepura


Install CQL interactive terminal:

sudo pip install cqlsh
like image 31
y durga prasad Avatar answered Oct 05 '22 01:10

y durga prasad