[Fixed]-ImportError: cannot import name 'GeoIP'

1👍

In my case, need to do:

brew install geoip

Then, check where Homebrew will put the GeoIP files. For example, output on my end is:

==> Pouring geoip-1.6.12.mojave.bottle.1.tar.gz
🍺  /usr/local/Cellar/geoip/1.6.12: 18 files, 553.0KB

So, set this in local settings so that Django’s GeoIP could locate it:

GEOIP_PATH = '/usr/local/Cellar/geoip/1.6.12/'

as per https://docs.djangoproject.com/en/dev/ref/contrib/gis/geoip2/#std:setting-GEOIP_PATH. After that, the import error is gone.

Leave a comment