Hiredis: Cannot install on ubuntu 14.10

Created on 9 Jun 2015  路  5Comments  路  Source: redis/hiredis

Error when installing Will on ubuntu 14.10:

In file included from src/hiredis.c:1:0:
    src/hiredis.h:4:20: fatal error: Python.h: No such file or directory
     #include <Python.h>
                        ^
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Ubuntu version:

$ uname -a
Linux ip-10-0-102-121 3.13.0-53-generic #89-Ubuntu SMP Wed May 20 10:34:39 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Here are the steps taken:

(clean machine, new AWS instance)

$ sudo pip install hiredis
sudo: unable to resolve host ip-10-0-102-121
The directory '/home/ubuntu/.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/ubuntu/.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.
Collecting hiredis
/usr/local/lib/python2.7/dist-packages/pip-7.0.3-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading hiredis-0.2.0.tar.gz (46kB)
    100% |################################| 49kB 2.7MB/s
Building wheels for collected packages: hiredis
  Running setup.py bdist_wheel for hiredis
  Complete output from command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build-OJDxMJ/hiredis/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpjtOVKVpip-wheel-:
  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/hiredis
  copying hiredis/version.py -> build/lib.linux-x86_64-2.7/hiredis
  copying hiredis/__init__.py -> build/lib.linux-x86_64-2.7/hiredis
  running build_clib
  building 'hiredis_for_hiredis_py' library
  creating build/temp.linux-x86_64-2.7
  creating build/temp.linux-x86_64-2.7/vendor
  creating build/temp.linux-x86_64-2.7/vendor/hiredis
  x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -c vendor/hiredis/read.c -o build/temp.linux-x86_64-2.7/vendor/hiredis/read.o
  x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -c vendor/hiredis/sds.c -o build/temp.linux-x86_64-2.7/vendor/hiredis/sds.o
  ar rc build/temp.linux-x86_64-2.7/libhiredis_for_hiredis_py.a build/temp.linux-x86_64-2.7/vendor/hiredis/read.o build/temp.linux-x86_64-2.7/vendor/hiredis/sds.o
  running build_ext
  building 'hiredis.hiredis' extension
  creating build/temp.linux-x86_64-2.7/src
  x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Ivendor -I/usr/include/python2.7 -c src/hiredis.c -o build/temp.linux-x86_64-2.7/src/hiredis.o
  In file included from src/hiredis.c:1:0:
  src/hiredis.h:4:20: fatal error: Python.h: No such file or directory
   #include <Python.h>
                      ^
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for hiredis
Failed to build hiredis
Installing collected packages: hiredis
  Running setup.py install for hiredis
    Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-OJDxMJ/hiredis/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-7z3BpS-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    running build_clib
    building 'hiredis_for_hiredis_py' library
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -c vendor/hiredis/read.c -o build/temp.linux-x86_64-2.7/vendor/hiredis/read.o
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -c vendor/hiredis/sds.c -o build/temp.linux-x86_64-2.7/vendor/hiredis/sds.o
    running build_ext
    building 'hiredis.hiredis' extension
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Ivendor -I/usr/include/python2.7 -c src/hiredis.c -o build/temp.linux-x86_64-2.7/src/hiredis.o
    In file included from src/hiredis.c:1:0:
    src/hiredis.h:4:20: fatal error: Python.h: No such file or directory
     #include <Python.h>
                        ^
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-OJDxMJ/hiredis/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-7z3BpS-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-OJDxMJ/hiredis

Most helpful comment

I also have the problem on Ubuntu 14 with Python3, and i solve it by sudo apt-get install python3-dev. It's my first time to know python-dev doesn't cover Python3... orz

All 5 comments

created from https://github.com/skoczen/will/issues/160

workaround:

apt-get install python-dev

That's not a workaround, that is the fix. If you want to install Python modules written in C you need the dev package to get the headers.

But when installing via pip:

sudo pip install hiredis

shouldn't it install the dependency also?
Or at least indicate in a message that pyhon-dev should be installed.

pip has no idea about your system nor does it know how to install using apt. There are even systems that just don't split up into dev and non-dev packages, so this is not needed.

I also have the problem on Ubuntu 14 with Python3, and i solve it by sudo apt-get install python3-dev. It's my first time to know python-dev doesn't cover Python3... orz

Was this page helpful?
0 / 5 - 0 ratings