当导入DataStax Cassandra驱动程序(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
pip install cassandra-driver
命令? - Ben Whaley-vv
运行你的Python,并执行from cassandra.cluster import Cluster
。你会看到它尝试查找包的位置。确保该包在PYTHONPATH中可用。 - Mikhail Stepura