python - 'Murmur3Partitioner' 的 C 扩展未编译

标签 python cassandra

我正在研究这个python-cassandra tutorial

当我运行此命令时

cluster = Cluster(
  contact_points=['127.0.0.1'],
  load_balancing_policy= 
     TokenAwarePolicy(DCAwareRoundRobinPolicy(local_dc='datacenter1')),
  default_retry_policy = RetryPolicy()
 )
session = cluster.connect('demo')

我收到以下错误:

>>> session = cluster.connect('mykeyspace')
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/usr/local/lib/python2.7/dist-packages/cassandra/cluster.py", 
          line 700, in connect
    self.load_balancing_policy.check_supported()
    File "/usr/local/lib/python2.7/dist-packages/cassandra/policies.py", 
          line 345, in check_supported
          (self.__class__.__name__, self._cluster_metadata.partitioner))
    Exception: TokenAwarePolicy cannot be used with the cluster partitioner
    (org.apache.cassandra.dht.Murmur3Partitioner) because the relevant C extension 
    for this driver was not compiled. See the installation instructions for details 
    on building and installing the C extensions.

但是,当我运行以下命令(应该按照文档中所述重建 C 扩展)时,我得到了一切正确的确认。

user1@mybox-VirtualBox:~$ sudo apt-get install gcc python-dev
[sudo] password for user1: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
gcc is already the newest version.
python-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 254 not upgraded.

我错过了什么吗?

最佳答案

安装 gcc 和 python-dev 后,您需要返回并重新安装 Cassandra Python 驱动程序。假设您还安装了编译 libev 的支持,整个序列如下所示:

$ sudo apt-get install gcc python-dev
$ sudo apt-get install libev4 libev-dev
$ sudo pip uninstall cassandra-driver
$ sudo pip install cassandra-driver

在第二次安装时,C 扩展应该可以正确编译。

关于python - 'Murmur3Partitioner' 的 C 扩展未编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27085384/

相关文章:

spring-boot - 如何使用 CassandraAutoConfiguration 在 spring boot 应用程序和 cassandra 之间配置 ssl?

python - 列上的 Pandas GroupBy 和 CumSum

Python正则表达式匹配源代码中以新行结尾的文本

python - 使用 Python 在内存中分配大数组

Java/Cas​​sandra 在设置 Frozen 属性时抛出错误

node.js - 使用数组查询 cassandra 数据库

hadoop - 我们可以使用Hive查询 map 集合吗

Python - 使用 Qt5 构建一个简单的网络浏览器

python - 通过给定的 geojson 分割包含 lat/lng 的 pandas DataFrame

java - 使用 Astyanax CQL3 API 批量插入?