使用pip安装django-iprestrict[geoip]:
➜ ~ sudo pip3 install django-iprestrict\[geoip\]
...此处省略好多行
Running setup.py bdist_wheel for GeoIP ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ur8tctju/GeoIP/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmp798t3yhtpip-wheel- --python-tag cp35:
/usr/lib/python3.5/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.5
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c py_GeoIP.c -o build/temp.linux-x86_64-3.5/py_GeoIP.o
py_GeoIP.c:23:19: fatal error: GeoIP.h: 没有那个文件或目录
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for GeoIP
Running setup.py clean for GeoIP
Running setup.py bdist_wheel for maxminddb ... done
Stored in directory: /home/lss/.cache/pip/wheels/15/76/41/255dfba221c2556c5e45dcf0d832ee63ea83dd151dada50b0f
Successfully built django-templatetag-handlebars pycountry maxminddb
Failed to build GeoIP
Installing collected packages: pytz, Django, django-templatetag-handlebars, pycountry, GeoIP, maxminddb, certifi, urllib3, idna, chardet, requests, geoip2, django-iprestrict
Running setup.py install for GeoIP ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ur8tctju/GeoIP/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-z4edljlo-record/install-record.txt --single-version-externally-managed --compile --user --prefix=:
/usr/lib/python3.5/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.5
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c py_GeoIP.c -o build/temp.linux-x86_64-3.5/py_GeoIP.o
py_GeoIP.c:23:19: fatal error: GeoIP.h: 没有那个文件或目录
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ur8tctju/GeoIP/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-z4edljlo-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-ur8tctju/GeoIP/
看报错信息发现应该是GeoIP这个包的问题,单独运行:
➜ ~ sudo pip3 install GeoIP
The directory '/home/lss/.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/lss/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting GeoIP
Downloading https://files.pythonhosted.org/packages/f2/7b/a463b7c3df8ef4b9c92906da29ddc9e464d4045f00c475ad31cdb9a97aae/GeoIP-1.3.2.tar.gz
Installing collected packages: GeoIP
Running setup.py install for GeoIP ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-o6bh_yap/GeoIP/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-1ryyzr40-record/install-record.txt --single-version-externally-managed --compile:
/usr/lib/python3.5/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.5
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c py_GeoIP.c -o build/temp.linux-x86_64-3.5/py_GeoIP.o
py_GeoIP.c:23:19: fatal error: GeoIP.h: 没有那个文件或目录
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-o6bh_yap/GeoIP/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-1ryyzr40-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-o6bh_yap/GeoIP/
果然报错,网上搜索类似好多这个报错信息的问题发现应该是缺少某个依赖包,不过还没有找到应该是什么包…
未完待续…