无法通过pip安装pylibmc

时间:2016-01-13 11:10:37

标签: python macos pip pylibmc

我试图在mac上安装pylibmc mac env是osx el capitan 10.11.2。

我试过了pip install pylibmc。但是我收到了以下错误。

我已安装下面的列表。

  • brew install libmemcached
  • 命令行工具
  • 导出CFLAGS = -Qunused-arguments @shell
  • 导出CPPFLAGS = -Qunused-arguments @shell

如何安装pylibmc ??

Installing collected packages: pylibmc
Running setup.py install for pylibmc
Complete output from command /Users/username/.virtualenvs/django-proj/bin/python2.7 -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-goDKgm/pylibmc/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-wxC5F1-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/username/.virtualenvs/django-proj/bin/../include/site/python2.7/pylibmc:
running install
running build
running build_py
creating build
creating build/lib.macosx-10.11-x86_64-2.7
creating build/lib.macosx-10.11-x86_64-2.7/pylibmc
copying pylibmc/__init__.py -> build/lib.macosx-10.11-x86_64-2.7/pylibmc
copying pylibmc/__main__.py -> build/lib.macosx-10.11-x86_64-2.7/pylibmc
copying pylibmc/client.py -> build/lib.macosx-10.11-x86_64-2.7/pylibmc
copying pylibmc/consts.py -> build/lib.macosx-10.11-x86_64-2.7/pylibmc
copying pylibmc/pools.py -> build/lib.macosx-10.11-x86_64-2.7/pylibmc
copying pylibmc/test.py -> build/lib.macosx-10.11-x86_64-2.7/pylibmc
running build_ext
building '_pylibmc' extension
creating build/temp.macosx-10.11-x86_64-2.7
clang -fno-strict-aliasing -fno-common -dynamic -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DUSE_ZLIB -I/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _pylibmcmodule.c -o build/temp.macosx-10.11-x86_64-2.7/_pylibmcmodule.o -fno-strict-aliasing
In file included from _pylibmcmodule.c:34:
./_pylibmcmodule.h:42:10: fatal error: 'libmemcached/memcached.h' file not found
#include <libmemcached/memcached.h>
         ^
1 error generated.
error: command 'clang' failed with exit status 1

3 个答案:

答案 0 :(得分:13)

首先需要安装

brew install libmemcached

通过此命令安装python包

pip install pylibmc --install-option="--with-libmemcached=/usr/local/Cellar/libmemcached/1.0.18/"

答案 1 :(得分:6)

安装dev包:

sudo apt-get install libmemcached-dev
sudo apt-get install zlib1g-dev

然后使用pip python包安装:

pip install pylibmc

检查requirements

的文档

答案 2 :(得分:0)

三个步骤,包括重启计算机时自动启动memcached服务器

  1. brew install libmemcached
  2. pip install pylibmc
  3. ln -s /usr/local/Cellar/memcached/1.4.24/homebrew.mxcl.memcached.plist~/ Library / LaunchAgents /(注意:您需要修改版本号为自己的版本,这里是1.4 0.24)
  4. launchctl load -w~ / Library / LaunchAgents / homebrew.mxcl.memcached.plist(注意:如果以后不想自动启动memacached服务器,可以使用unload命令)