繁体   English   中英

cassandra-driver:ImportError:没有名为队列的模块

[英]cassandra-driver: ImportError: No module named queue

我正在OSX 10.11上用pip安装cassandra驱动程序。 直接从点子开始,cassandra驱动程序会出现以下错误:

traceback (most recent call last):   File "syncS3ToCassandra.py", line 19, in <module>
from cassandra.cluster import Cluster   File "cassandra/cluster.py", line 48, in init cassandra.cluster (cassandra/cluster.c:74747)   
File "cassandra/connection.py", line 38, in init cassandra.connection (cassandra/connection.c:28007) 
ImportError: No module named queue

我没有尝试从源代码构建cassandra驱动程序,但建议使用pip。 这是我的代码:

from cassandra.cluster import Cluster
from cassandra.policies import DCAwareRoundRobinPolicy

cluster = Cluster()
session = cluster.connect('foo')

我也在我的Mbp上遇到了这个问题。 还有其他一些我无法卸载的问题。 我使用easy_install将版本从1.4.1更新到1.10.0进行修复。

$sudo easy_install -U six

希望它能对您有所帮助。

从源代码中,您需要安装软件包6 ,它应该有一个包含模块queue.py的子软件包移动

38    from six.moves.queue import Queue, Empty

您可以尝试重新安装六个吗?

  1. pip卸载六
  2. 点安装六

由于cassandra-driver (版本3.4.1)仅作为.tar.gz软件包提供,因此您必须从源代码重新编译它。 这就是点子。

我已成功将其安装在OSX 10.11.5上(至少花了一分钟时间进行编译)。

我尝试这样:

$ python
Python 2.7.10 (default, Oct 23 2015, 19:19:21) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from cassandra.cluster import Cluster
>>> from cassandra.policies import DCAwareRoundRobinPolicy
>>> cluster = Cluster()
>>> session = cluster.connect('foo')
Traceback (most recent call last):
  ...
cassandra.cluster.NoHostAvailable: ('Unable to connect to any servers', {'127.0.0.1': error(61, "Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused")})

最后一个错误是正常的,因为我没有服务器。

编辑:在Python 3.5中安装

我已在OSX 10.11.5上的Python 3.5.1中成功安装并测试了该驱动程序(尽我所能)。

$ python
Python 3.5.1 (v3.5.1:37a07cee5969, Dec  5 2015, 21:12:44)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from cassandra.cluster import Cluster
>>> from cassandra.policies import DCAwareRoundRobinPolicy
>>> cluster = Cluster()
>>> session = cluster.connect('foo')
Traceback (most recent call last):
...
cassandra.cluster.NoHostAvailable: ('Unable to connect to any servers'[..])

我已经使用基本前缀“ /Library/Frameworks/Python.framework/Versions/3.5”创建了virtualenv。

我通过以下方式更新〜/ .profile来解决此问题:

export PATH=/usr/local/bin:/usr/local/sbin:$PATH

和安装python-2.7.11

$ brew install python

然后重启我的shell。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM