14

I'm trying to install pylibmc on mac.
mac env is osx el capitan 10.11.2.

I tried pip install pylibmc. but I received following error.

I already installed list below.

  • brew install libmemcached
  • Command Line Tools
  • export CFLAGS=-Qunused-arguments @shell
  • export CPPFLAGS=-Qunused-arguments @shell

How can I install 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
naohide_a
  • 1,116
  • 2
  • 13
  • 30

4 Answers4

29

first you need to install

brew install libmemcached

than install python package by this command

pip install pylibmc --install-option="--with-libmemcached=/usr/local/Cellar/libmemcached/1.0.18/"
Atul Jain
  • 1,053
  • 11
  • 36
  • Thank you so much. I could successfully install pylibmc. – naohide_a Jan 13 '16 at 11:27
  • I used `/usr/local/Cellar/libmemcached` (without specifying the version) and it worked too. – reubano Aug 10 '17 at 15:06
  • Thank you very much for this answer. – hygull Feb 04 '19 at 13:42
  • Depending on the Homebrew version / setup `libmemcached` may be elsewhere, checkout it's location after installing with `brew info libmemcached` and change the install option accordingly. Mine was in `/opt/homebrew/Cellar/libmemcached`. – José Jan 09 '23 at 23:18
13

Install dev package:

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

then install with pip the python package :

pip install pylibmc

Check documentation for requirements

  • Check this @naohide. –  Jan 13 '16 at 11:32
  • I use this in my centos server `yum install libmemcached-devel` and then pylibmc was successfully installed. Hopes this will be helpful for others who got the same issue – Alfred Dec 30 '16 at 01:39
0

three steps including automatically start memcached server when restarting computers

  1. brew install libmemcached
  2. pip install pylibmc
  3. ln -s /usr/local/Cellar/memcached/1.4.24/homebrew.mxcl.memcached.plist ~/Library/LaunchAgents/ (note: you need to modify the version no to your own one, here is 1.4.24)
  4. launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist (note: if you do not want auto-start memacached server later, you can use unload command)
X.C.
  • 703
  • 9
  • 18
0

Update to @Atul's accepted answer above -- first you need to install

brew install libmemcached

then check version installed with

ls /usr/local/Cellar/libmemcached (As of today 1.0.18_2 is the latest)

Now install python package by substituting above version in this command

pip install pylibmc --install-option="--with libmemcached=/usr/local/Cellar/libmemcached/<version>"

e.g.

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

coder
  • 39
  • 6