我安装了一些依赖项:
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/