Memcached installation changed and fails

Hi all,

Installing/configuring memcached fails when calling
pip install pylibmc
Error message:

root@seafile:/opt/seafile# pip install pylibmc
Collecting pylibmc
  Downloading pylibmc-1.5.1.tar.gz (59kB)
    100% |████████████████████████████████| 61kB 1.3MB/s
Building wheels for collected packages: pylibmc
  Running setup.py bdist_wheel for pylibmc ... error
  Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-9dAy1v/pylibmc/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpxpsx1Epip-wheel- --python-tag cp27:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-2.7
  creating build/lib.linux-x86_64-2.7/pylibmc
  copying src/pylibmc/__main__.py -> build/lib.linux-x86_64-2.7/pylibmc
  copying src/pylibmc/consts.py -> build/lib.linux-x86_64-2.7/pylibmc
  copying src/pylibmc/__init__.py -> build/lib.linux-x86_64-2.7/pylibmc
  copying src/pylibmc/pools.py -> build/lib.linux-x86_64-2.7/pylibmc
  copying src/pylibmc/client.py -> build/lib.linux-x86_64-2.7/pylibmc
  copying src/pylibmc/test.py -> build/lib.linux-x86_64-2.7/pylibmc
  running build_ext
  building '_pylibmc' extension
  creating build/temp.linux-x86_64-2.7
  creating build/temp.linux-x86_64-2.7/src
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DUSE_ZLIB -I/usr/include/python2.7 -c src/_pylibmcmodule.c -o build/temp.linux-x86_64-2.7/src/_pylibmcmodule.o -fno-strict-aliasing -std=c99
  In file included from src/_pylibmcmodule.c:34:0:
  src/_pylibmcmodule.h:42:36: fatal error: libmemcached/memcached.h: Datei oder Verzeichnis nicht gefunden
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  Failed building wheel for pylibmc
  Running setup.py clean for pylibmc
Failed to build pylibmc
Installing collected packages: pylibmc
  Running setup.py install for pylibmc ... error
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-9dAy1v/pylibmc/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-q0Ld74-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    creating build/lib.linux-x86_64-2.7/pylibmc
    copying src/pylibmc/__main__.py -> build/lib.linux-x86_64-2.7/pylibmc
    copying src/pylibmc/consts.py -> build/lib.linux-x86_64-2.7/pylibmc
    copying src/pylibmc/__init__.py -> build/lib.linux-x86_64-2.7/pylibmc
    copying src/pylibmc/pools.py -> build/lib.linux-x86_64-2.7/pylibmc
    copying src/pylibmc/client.py -> build/lib.linux-x86_64-2.7/pylibmc
    copying src/pylibmc/test.py -> build/lib.linux-x86_64-2.7/pylibmc
    running build_ext
    building '_pylibmc' extension
    creating build/temp.linux-x86_64-2.7
    creating build/temp.linux-x86_64-2.7/src
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DUSE_ZLIB -I/usr/include/python2.7 -c src/_pylibmcmodule.c -o build/temp.linux-x86_64-2.7/src/_pylibmcmodule.o -fno-strict-aliasing -std=c99
    In file included from src/_pylibmcmodule.c:34:0:
    src/_pylibmcmodule.h:42:36: fatal error: libmemcached/memcached.h: Datei oder Verzeichnis nicht gefunden
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-9dAy1v/pylibmc/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-q0Ld74-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-9dAy1v/pylibmc/

What am i doing wrong?

Besides that I’m wondering, why there is a new installation method for memcached. The one I used for my old seafile server says:

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
        'LOCATION': '127.0.0.1:11211',
    }
}

instead of the new one:

CACHES = {
    'default': {
        'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
        'LOCATION': '127.0.0.1:11211',
    }
}

What’s the difference?

Thanks,
Jochen

Hi Jochen,

as far as i remember running this command: sudo apt-get install libmemcached-dev zlib1g-dev should help. Maybe you also have to run sudo apt-get install python-dev.

I think this change was done because the old memcached library was not compatible with Django 1.8.

3 Likes

Hi Marcus,

Thanks, that did the trick!:slight_smile:
Maybe the devs should add this to the manual!?

And thank you for clarification about the deprecated memcached library!

Cheers,
Jochen

@Jochen, do you still remember if you installed zlib1g-dev only or it was necessary python-dev as well? Is for the documentation

Because i’ve installed a fresh seafile server some days ago, i think i had to install both packages. I’m not 100% sure, but already looked at the system and both packages are installed currently.

@jobenvil, I don’t know whether it was necessary or not nor do I remember why I installed it, but I have both of em installed.

Since i’ve installed a new server today, it’s enough to install only:

1 Like

This is the what you need to run it:
sudo apt-get install libmemcached-dev zlib1g-dev

should bee good if you changed it in the manual.

Also one question, should the pip command really bee as root (sudo)?

seafile@Nohatech:~/nohatech/seafile-server-latest$ sudo pip install pylibmc
The directory '/home/seafile/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/seafile/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

I’m getting that kind of warning.

Yes, i wrote this already.

You can check the permissions of these folders. I run it always as root.

Do you run seafile as root all the time?

That’s not good from a security point of view

No (i know that ;-)), but for installation of packages you have to do it as a root user.

I did also run the installation as root trough sudo command, and that’s when I did get that warning.

I see, but i never saw this message before.

Try sudo -H pip install pylibmc

I’m going to do a clean install tomorrow then I’ll test this.