我正在研究这个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/