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.
yum install -y geoip-devel
[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