0

我在 Mac OS Lion 上遇到了 pylibmc 问题。

libmemcached — 1.0.4

pylibmc — 1.2.3

$ python
Python 2.7.1 (r271:86832, Jun 25 2011, 05:09:01) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pylibmc
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/pylibmc/__init__.py", line 70, in <module>
    import _pylibmc
ImportError: dlopen(/Library/Python/2.7/site-packages/_pylibmc.so, 2): Symbol not found: _memcached_add
  Referenced from: /Library/Python/2.7/site-packages/_pylibmc.so
  Expected in: flat namespace
 in /Library/Python/2.7/site-packages/_pylibmc.so

但它适用于 sudo!

$ sudo python
Password:
Python 2.7.1 (r271:86832, Jun 25 2011, 05:09:01) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pylibmc
>>> 

有任何想法吗?

4

2 回答 2

2

在 32 位模式下安装解决了这个问题。

  1. 您需要在 32 位模式下安装 libevent

    brew install --universal libevent
    
  2. 接下来下载 libmemcached 源(1.0.8 版本适用于我)并为 32 位拱配置 force:

    ./configure --build=i386-apple-darwin11.4.2 "CFLAGS=-m32" "CXXFLAGS=-m32" "LDFLAGS=-m32"
    make
    sudo make install
    

    其中 11.4.2 是内核版本

  3. 重新安装 pylibmc

    sudo pip uninstall pylibmc
    sudo pip install pylibmc
    
  4. 现在它可以工作了

    $ python -c 'import pylibmc'
    $
    
于 2012-10-29T13:30:49.837 回答
0

看起来像是 libmemcached 的构建和/或安装问题。也许您可以查看问题 #101?https://github.com/lericson/pylibmc/issues/101

于 2012-09-27T18:31:56.980 回答