centos7上安装annoy

检查信息:

# cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core)

# python -V
Python 2.7.5

安装pip

yum -y install python-pip

安装annoy

# pip install annoy
Collecting annoy
  Downloading https://files.pythonhosted.org/packages/b5/28/f8ce7400344090bb5cfa1c9fae3fdb03b9438db082d458686442633d82a3/annoy-1.15.0.tar.gz (635kB)
    100% |████████████████████████████████| 645kB 155kB/s 
Installing collected packages: annoy
  Running setup.py install for annoy ... error
    Complete output from command /usr/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-f3WUsu/annoy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-IEqdkr-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/annoy
    copying annoy/__init__.py -> build/lib.linux-x86_64-2.7/annoy
    running build_ext
    building 'annoy.annoylib' extension
    creating build/temp.linux-x86_64-2.7
    creating build/temp.linux-x86_64-2.7/src
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.7 -c src/annoymodule.cc -o build/temp.linux-x86_64-2.7/src/annoymodule.o -O3 -ffast-math -fno-associative-math -march=native
    src/annoymodule.cc:17:20: fatal error: Python.h: No such file or directory
     #include "Python.h"
                        ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    
    ----------------------------------------
Command "/usr/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-f3WUsu/annoy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-IEqdkr-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-f3WUsu/annoy/
You are using pip version 8.1.2, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

解决该问题:

# yum install python-devel

之后,就可以安装annoy了。

你可能感兴趣的:(python)