2014-11-23 47 views
1

我正在研究這個python-cassandra tutorial'Murmur3Partitioner'的C擴展未編譯

當我運行此命令

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擴展,因爲它在文件中說,我得到一切正確的確認。

[email protected]:~$ 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. 

我錯過了什麼?

回答

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擴展應正確編譯。