2016-01-13 247 views
3

我正試圖在mac上安裝pylibmc。
mac env is osx el capitan 10.11.2。我試過pip install pylibmc。但我收到以下錯誤。無法安裝pylibmc pip

我已經安裝了下面的列表。

  • 釀造安裝libmemcached
  • 命令行工具
  • 出口CFLAGS = -Qunused論點@shell
  • 出口CPPFLAGS = -Qunused論點@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 
+0

看來libmemcached沒有正確安裝 –

回答

11

首先你需要安裝

brew install libmemcached 

比這個命令安裝Python包

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

非常感謝。我可以成功安裝pylibmc。 – naohide

+0

我使用了'/ usr/local/Cellar/libmemcached'(沒有指定版本),它也起作用。 – reubano

3

安裝dev軟件包:

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

然後用畫中畫的Python安裝包:

pip install pylibmc 

檢查文檔requirements

+0

檢查此@nohide。 – 2016-01-13 11:32:34

+4

你真的認爲apt-get會在osx上工作 –

+0

我在我的centos服務器'yum install libmemcached-devel'中使用這個,然後成功安裝了pylibmc。希望這對有同樣問題的其他人有幫助 – Alfred

0

三個步驟,包括重新啓動計算機時

自動啓動memcached服務器
  1. 釀造安裝libmemcached
  2. PIP安裝pylibmc
  3. LN -s在/ usr /本地/Cellar/memcached/1.4.24/homebrew.mxcl.memcached.plist〜/ Library/LaunchAgents /(注意:你需要修改版本號給你自己的,這裏是1.4.24)
  4. launchctl加載-w〜/ Library/LaunchAgents/homebrew.mxcl.memcached.plist(注意:如果您不想在稍後自動啓動memacached服務器,則可以使用unload命令)