pip安装GeoIP时报fatal error: GeoIP.h: No such file or directory

CentOS 7下使用pip安装GeoIP包时报如下错误,提示缺少GeoIP.h头文件

[root@master-60-5 python]# pip3 install geoip
Looking in indexes: https://pypi.doubanio.com/simple/
Collecting geoip
  Downloading https://pypi.doubanio.com/packages/f2/7b/a463b7c3df8ef4b9c92906da29ddc9e464d4045f00c475ad31cdb9a97aae/GeoIP-1.3.2.tar.gz (20 kB)
Building wheels for collected packages: geoip
  Building wheel for geoip (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ej1hc8gn/geoip_a610de910634447f89f7f42ca2d53d17/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ej1hc8gn/geoip_a610de910634447f89f7f42ca2d53d17/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-ksxvyvzp
       cwd: /tmp/pip-install-ej1hc8gn/geoip_a610de910634447f89f7f42ca2d53d17/
  Complete output (14 lines):
  /usr/lib64/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'bugtrack_url'
    warnings.warn(msg)
  running bdist_wheel
  running build
  running build_ext
  building 'GeoIP' extension
  creating build
  creating build/temp.linux-x86_64-3.6
  gcc -pthread -Wno-unused-result -Wsign-compare -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/python3.6m -c py_GeoIP.c -o build/temp.linux-x86_64-3.6/py_GeoIP.o
  py_GeoIP.c:23:19: fatal error: GeoIP.h: No such file or directory
   #include "GeoIP.h"
                     ^
  compilation terminated.
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for geoip
  Running setup.py clean for geoip
Failed to build geoip
Installing collected packages: geoip
    Running setup.py install for geoip ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ej1hc8gn/geoip_a610de910634447f89f7f42ca2d53d17/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ej1hc8gn/geoip_a610de910634447f89f7f42ca2d53d17/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-i0zjj460/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6m/geoip
         cwd: /tmp/pip-install-ej1hc8gn/geoip_a610de910634447f89f7f42ca2d53d17/
    Complete output (14 lines):
    /usr/lib64/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'bugtrack_url'
      warnings.warn(msg)
    running install
    running build
    running build_ext
    building 'GeoIP' extension
    creating build
    creating build/temp.linux-x86_64-3.6
    gcc -pthread -Wno-unused-result -Wsign-compare -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/python3.6m -c py_GeoIP.c -o build/temp.linux-x86_64-3.6/py_GeoIP.o
    py_GeoIP.c:23:19: fatal error: GeoIP.h: No such file or directory
     #include "GeoIP.h"
                       ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ej1hc8gn/geoip_a610de910634447f89f7f42ca2d53d17/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ej1hc8gn/geoip_a610de910634447f89f7f42ca2d53d17/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-i0zjj460/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6m/geoip Check the logs for full command output.
  • 解决方法,安装geoip-devel
yum install -y geoip-devel
  • 安装GeoIP成功
[root@master-60-5 python]# pip3 install geoip
Looking in indexes: https://pypi.doubanio.com/simple/
Collecting geoip
  Using cached https://pypi.doubanio.com/packages/f2/7b/a463b7c3df8ef4b9c92906da29ddc9e464d4045f00c475ad31cdb9a97aae/GeoIP-1.3.2.tar.gz (20 kB)
Building wheels for collected packages: geoip
  Building wheel for geoip (setup.py) ... done
  Created wheel for geoip: filename=GeoIP-1.3.2-cp36-cp36m-linux_x86_64.whl size=46113 sha256=4ede072ab7c175b13db58056d25028c7bec3dfd28a7fe163bd04a5ffea710b45
  Stored in directory: /root/.cache/pip/wheels/cc/88/79/80e1c0a90f10724b3bed4cd8df3fb5ed1a6c14889beb018ebc
Successfully built geoip
Installing collected packages: geoip
Successfully installed geoip-1.3.2

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值