Error when install pylibmc using pip

PythonMemcachedOsx LionLibmemcached

Python Problem Overview


Hello when I attempt to install pylibmc on OSX Lion using pip I get the following error:

./_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

Any clues at how to solve this issue?

Python Solutions


Solution 1 - Python

libmemcached may also be installed using Homebrew.

brew install libmemcached

After that, pip install pylibmc worked for me without needing to specify any additional arguments.

Solution 2 - Python

It's in the libmemcached package. To install it using macports:

sudo port install libmemcached

Then, assuming you're using pip:

pip install pylibmc --install-option="--with-libmemcached=/opt/local"

or

LIBMEMCACHED=/opt/local pip install pylibmc

as explained in the pylibmc docs.

Solution 3 - Python

I solved this issue by checking where memcached is installed

$ which memcached
/usr/local/bin/memcached

and then setting LIBMEMCACHED environment variable before pip install:

$ export LIBMEMCACHED=/usr/local
$ pip install pylibmc

Solution 4 - Python

Answer for Ubuntu users:

sudo apt install libmemcached-dev zlib1g-dev

Solution 5 - Python

I have the same problem because i have installed MEMCACHED and not LIBMEMCACHED, so, to resolve:

brew uninstall memcached #to remove wrong package

brew install libmemcached #install correct lib

pip install pylibmc

Its Works for me!

: )

Solution 6 - Python

For those finding this answer on Fedora:

sudo yum install libmemcached-devel

Solution 7 - Python

i fixed this by installing memcached from port

you should install first macports from http://www.macports.org/

then run this command

sudo port install memcached

after that download the pylibmc from the pypi http://pypi.python.org/pypi/pylibmc extract .tar.gz file then

python setup.py install --with-libmemcached=/opt/local

Solution 8 - Python

this code is worked for me

  sudo apt-get install libmemcached-dev zlib1g-dev
    
  LIBMEMCACHED=/opt/local pip install pylibmc

Solution 9 - Python

Hit the same error with macOS High Sierra, Python3.6 installed with brew. Solution for me was to export these flags, mentioned in this comment: https://stackoverflow.com/questions/14803310/error-when-install-pylibmc-using-pip/33663121#comment62898499_19432949

export LDFLAGS="-L/usr/local/lib"
export CPPFLAGS="-I/usr/local/include"

After that, pip install run just fine.

Solution 10 - Python

Sometimes the X-Code Command Line Tools need to be installed.

 xcode-select -p

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionharristraderView Question on Stackoverflow
Solution 1 - PythonJeremyView Answer on Stackoverflow
Solution 2 - PythonMike FogelView Answer on Stackoverflow
Solution 3 - PythonAidas BendoraitisView Answer on Stackoverflow
Solution 4 - PythonfluffyView Answer on Stackoverflow
Solution 5 - PythonGiuseppe LopesView Answer on Stackoverflow
Solution 6 - PythonJamieView Answer on Stackoverflow
Solution 7 - PythonmohdView Answer on Stackoverflow
Solution 8 - PythonSarath AkView Answer on Stackoverflow
Solution 9 - PythonValtteri LuomaView Answer on Stackoverflow
Solution 10 - PythonTwitchView Answer on Stackoverflow