python - 我可以让 pylibmc 与 python 3.2 一起使用吗?

标签 python python-3.x memcached

我安装了一些依赖项:

sudo apt-get install python3.2-dev
sudo apt-get install libmemcached-dev

并尝试:

pip install pylibmc

在 virtualenv 中使用我的 python 3.2

但是有这个:

_pylibmcmodule.c:77:9: error: ‘PylibMC_Client’ has no member named ‘ob_type’
_pylibmcmodule.c:1812:39: error: ‘PyInt_Type’ undeclared (first use in this function)
_pylibmcmodule.c:1841:53: error: ‘PylibMC_Client’ has no member named ‘ob_type’
error: command 'gcc' failed with exit status 1

我该如何解决这个问题?
(它适用于 python 2.7)

最佳答案

编辑:看起来它正在“master”中工作,但尚未发布。

我写了一些 python 3 支持 - see my repo branch

我修改了测试,但仍有一些失败:

1. "test_touch" (test_client.py)  

对于 python 2 和 3,它对我来说都失败了。即使对于未更改的代码也是如此。 (看起来像我的内存缓存问题 - 不知道)

>       ok_(self.mc.touch(touch_test, 5))
E       SystemError: error return without exception set

2. "test_cas" (test_client.py)

仅对 python 3 失败。Python 2 没问题。

>           rv, cas = mc.gets(k)
E           ValueError: gets without cas behavior

这可能是由于使用 pickle 保存 Integer 对象引起的。
负责的代码是:

} else if (PyLong_Check(value_obj)) {
    serialized->flags |= PYLIBMC_FLAG_LONG;
    PyObject* tmp = PyNumber_Long(value_obj);
    store_val = PyObject_Bytes(tmp);
    Py_DECREF(tmp);

我无法在 python 3 中使用它,因为 PyObject_Bytes generates an error :

>       ok_(mc.set(k, 0))
E       TypeError: 'int' object is not iterable

我运行这样的测试:

py.test tests/test_client.py

关于python - 我可以让 pylibmc 与 python 3.2 一起使用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15977475/

相关文章:

java - 如何从应用程序引擎上的 memcached 获取字符串 - java

python - 如何格式化 boto aws sdk 的 JSON?

python - Pandas 数据框中的条件分组

python - Matplotlib:从主轴映射值的次轴

Python 列表问题

python - 访问嵌套字典中的数据时发生 KeyError

memcached - memcache,多实例与单实例

mysql - 使用 Memcache 提高 MySQL 查询性能

python - 将 DataFrame 中的值插入另一个 DataFrame

python - 如何在 python 中一次读取一个字符串