Error when install pylibmc using pip
Asked Answered
T

11

77

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?

Trista answered 10/2, 2013 at 22:25 Comment(2)
Do you have the libmemcached headers installed anywhere?Rafaelrafaela
Thanks, I faced this error while installing requirements for running djangoproject's tests. Posting it here so that if somehow new contributors face this issue and reach here, they can confidently rely on the solution brew install libmemcachedBlotto
K
143

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.

Knurled answered 17/10, 2013 at 17:3 Comment(8)
I installed it using homebrew and it was correctly linked, although pylibmc couldn't find it either way. So I had to point the libmemcached directory when installing pylibmc by running sudo pip install pylibmc --install-option="--with-libmemcached=/usr/local/Cellar/libmemcached/1.0.18/"Burcham
You can try brew unlink libmemcached, then brew link libmemcached. In my case the links were messed up. This should create links such that /usr/local/include/libmemcached/memcached.h exists.Seton
These solutions didn't work for me. I had to export CPPFLAGS="-I/usr/local/include" and export LDFLAGS="-L/usr/local/lib"Gravelblind
brew unlink libmemcached then brew link memcached worked for me! Thanks @SetonPrecision
The defaults have changed at some point and you need to make sure CFLAGS/LDFLAGS are set. The best way to do this is to use pkg-config (brew install pkg-config if you don't have it) so the current installed version is used for the include & library files: CFLAGS=$(pkg-config --cflags libmemcached) LDFLAGS=$(pkg-config --libs libmemcached) pip install pylibmcFeuillant
I am installing pylibmc on windows but it is failing due to libmemcached and while installing libmemcached it is giving error of cmemcached_imp.c cannot be executed? Any help for windows platform @ChrisAdamsWinthrop
With modern installations of Homebrew, you may need to point to the new Homebrew root which is no longer in /usr/local: LIBMEMCACHED=/opt/homebrew pip install pylibmcJordison
CPPFLAGS="-I/opt/homebrew/include" pipenv install worked for me for M1, have not tried the shorter path though.Oppenheimer
G
38

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.

Gilli answered 19/2, 2013 at 23:27 Comment(1)
Worked, but I had to prepend a 'sudo' before the pipCaesium
K
33

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
Kissinger answered 12/11, 2015 at 1:48 Comment(5)
By the way, I have OS X El Capitan.Kissinger
This is the on for El CapitanSeverus
Works for me on macOS Sierra^^Inductile
Worked for me on macOS Mojave, python3.7Ganny
memcached not foundPolish
R
18

Answer for Ubuntu users:

sudo apt install libmemcached-dev zlib1g-dev
Redfin answered 1/7, 2019 at 20:5 Comment(1)
Fixed it for me! Verified on 18.0.4 ltsChrisman
C
7

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!

: )

Cream answered 20/5, 2015 at 13:0 Comment(1)
Brew declined to uninstall memcached because libmemcached is an installed dependency; so I expect what you've actually done is reinstall memcached.Wellwisher
T
6

For those finding this answer on Fedora:

sudo yum install libmemcached-devel

Tympanist answered 7/6, 2015 at 22:38 Comment(0)
S
3

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: Error when install pylibmc using pip

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

After that, pip install run just fine.

Southey answered 10/1, 2019 at 9:45 Comment(0)
W
2

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
Wickedness answered 10/2, 2013 at 22:44 Comment(0)
P
2

this code is worked for me

  sudo apt-get install libmemcached-dev zlib1g-dev

  LIBMEMCACHED=/opt/local pip install pylibmc
Penitence answered 30/5, 2017 at 17:19 Comment(0)
L
1

This worked for me with osx 14.1.1 on an M1 Mac:

brew install libmemcached
export LIBMEMCACHED="/opt/homebrew"

pip install pylibmc
Lozar answered 11/12, 2023 at 22:35 Comment(0)
H
0

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

 xcode-select -p
Heidyheifer answered 20/10, 2015 at 20:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.