未编译'Murmur3Partitioner'的C扩展名

时间:2014-11-23 03:47:17

标签: 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.

我错过了什么吗?

1 个答案:

答案 0 :(得分:2)

安装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扩展应该正确编译。