我收到未知的 geoip2 错误

I am getting unknown geoip2 error

我正在尝试测试 geoip 但它不起作用,我执行了以下步骤:-

$ pip install geoip2

settings.py

GEOIP_PATH = os.path.join(BASE_DIR,  'geoip')
INSTALLED_APPS = [ 'geoip2', ]

在航站楼

$./manage.py shell
$ from django.contrib.gis.geoip2 import GeoIP2
$ g = GeoIP2()

我收到错误,即

raise GeoIP2Exception('GeoIP path must be a valid file or directory.') django.contrib.gis.geoip2.base.GeoIP2Exception: GeoIP path must be a valid file or directory.

来自 Docs:

The GeoIP2 object is a wrapper for the MaxMind geoip2 Python library. 1

In order to perform IP-based geolocation, the GeoIP2 object requires the geoip2 Python library and the GeoIP Country and/or City datasets in binary format (the CSV files will not work!). Grab the GeoLite2-Country.mmdb.gz and GeoLite2-City.mmdb.gz files and unzip them in a directory corresponding to the GEOIP_PATH setting.

Additionally, it is recommended to install the libmaxminddb C library, so that geoip2 can leverage the C library’s faster speed.

确保您已完成上述操作,否则系统将无法运行。