Centos7下安装annoy报错与对应的解决方案

annoy简单介绍

annoy是高维空间求近似最近邻的一个开源库。其官网介绍如下:
Annoy (Approximate Nearest Neighbors Oh Yeah) is a C++ library with Python bindings to search for points in space that are close to a given query point. It also creates large read-only file-based data structures that are mmapped into memory so that many processes may share the same data.
annoy官网连接

在Centos7环境下 安装annoy的方式

官网介绍:
To install, simply do pip install --user annoy to pull down the latest version from PyPI
在Centos7中,Python2.7环境下,用pip执行:

pip install --user annoy

后执行过程中报如下错误:

ERROR: Command errored out with exit status 1:
     command: /usr/bin/python2 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-EsJwOr/annoy/setup.py'"'"'; __file__='"'"'/tmp/pip-install-EsJwOr/annoy/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-record-69PUs8/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /root/.local/include/python2.7/annoy
         cwd: /tmp/pip-install-EsJwOr/annoy/
    Complete output (14 lines):
    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 -D_CRT_SECURE_NO_WARNINGS -march=native -O3 -ffast-math -fno-associative-math
    gcc: error trying to exec 'cc1plus': execvp: No such file or directory
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python2 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-EsJwOr/annoy/setup.py'"'"'; __file__='"'"'/tmp/pip-install-EsJwOr/annoy/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-record-69PUs8/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /root/.local/include/python2.7/annoy Check the logs for full command output.

原因及解决方案

是由于c++库版本问题导致执行失败,解决办法更新gcc,更新gcc方式有许多帖子讲的过于复杂,建议参考:
stackoverflow上关于升级gcc方式
核心命令如下:

yum install centos-release-scl
yum install devtoolset-7-gcc*
scl enable devtoolset-7 bash
which gcc
gcc --version

升级完gcc后重新安装即可,祝大家学习和使用愉快!!!

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值