【发布时间】:2014-04-22 09:10:17
【问题描述】:
导入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
这是代码
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吗? -
你这样做也是从源代码编译的
-
使用
-vv运行你的python 并执行from cassandra.cluster import Cluster。你会看到它试图在哪里找到包。确保包在 PYTHONPATH 中可用 -
它在我的 python 路径中也列在 pip 中