【问题标题】:cassandra-driver: ImportError: No module named queuecassandra-driver:ImportError:没有名为队列的模块
【发布时间】:2016-10-06 13:59:40
【问题描述】:

我正在 OSX 10.11 上使用 pip 安装 cassandra-driver。 直接从 pip 出来,cassandra-driver 给出了这个错误:

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-driver,但 pip 是推荐的方法。这是我的代码:

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

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

【问题讨论】:

  • 好像OSX 10.11预装了6个1.4.1,用pip安装6个不会更新链接。

标签: python cassandra datastax


【解决方案1】:

我的 mbp 也遇到了这个问题。而且还有一些其他的问题我卸载不了六。我使用 easy_install 将版本从 1.4.1 更新到 1.10.0 来修复它。

$sudo easy_install -U six

希望对你有帮助。

【讨论】:

    【解决方案2】:

    从源代码中,您需要安装包 six,它应该有一个子包 moves,其中包含一个模块 queue.py

    38    from six.moves.queue import Queue, Empty
    

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

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

    【讨论】:

    • 看来六个有问题,我重新安装它并在 pip 上获得了 1.10 版本,但是运行 python -c "import Six; print Six.__version__" 给了我 1.4.1 版本。
    • 确实不好闻
    • 面临同样的问题并看到相同的六个版本差异(来自 pip 的 1.4.1 与 1.10).. 对此还有什么建议吗?
    【解决方案3】:

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

    我在 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。

    【讨论】:

    • 您的安装方式有什么特别之处吗?有/没有 cython 或 libev?
    • 好吧,当我升级到 El Capitan 时,我需要安装 XCode 命令行工具。命令行工具包是一个独立的小型包,可从 Xcode 单独下载,它允许您在 OS X 中进行命令行开发。请参阅我的 GCC 版本。注意:我尝试使用 Python 2。
    【解决方案4】:

    我通过更新我的 ~/.profile 解决了这个问题:

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

    并安装 python-2.7.11

    $ brew install python
    

    然后重新启动我的 shell。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-20
      • 2011-06-23
      • 1970-01-01
      • 2017-09-23
      • 2021-10-12
      相关资源
      最近更新 更多