Python/django : Cannot import GeoIP

这一生的挚爱 提交于 2019-12-06 16:52:53

It appears you need to install a C library in order to use GeoIP.

Here is a snippet from the file that is throwing that error.

# The shared library for the GeoIP C API.  May be downloaded
#  from http://www.maxmind.com/download/geoip/api/c/
if lib_path:
    lib_name = None
else:
    # TODO: Is this really the library name for Windows?
    lib_name = 'GeoIP'

Once you have it installed somewhere you need to reference it in your settings.py

GEOIP_LIBRARY_PATH = '/whatever'

The library was trying to tell you this, but it seems that there is a bug that prevents it from raising the correct error. https://github.com/django/django/pull/103

Previously i was facing this issue : from django.contrib.gis.geoip import GeoIP ImportError: cannot import name GeoIP

which is solved when i install this package.

yum install GeoIP-devel -y
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!