Django:ImportError:无法导入名称'GeoIP2'

问题描述 投票:1回答:3

我试图建立geoip2为GeoDjango内置按the instructions

出于某种原因,包装不导入功能。它的工作之前,我下载了数据库,并在我的设置指着他们,但由于某种原因,我现在无法加载GeoIP2(甚至当我在settings.py注释掉线)。我应该如何解决呢?

Python 3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 17:26:49) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import geoip2
>>>
>>> from django.contrib.gis.geoip2 import GeoIP2
Traceback (most recent call last):
  File "<console>", line 1, in <module>
ImportError: cannot import name 'GeoIP2'
>>>

编辑:我可以看到源文件(我没有修改)中正确地列出的GeoIP2功能。怎么可能被防止它加载?

我正在运行的Django 1.11.4

如果我输入django.contrib.gis.geoip2这就是它的财产__path__

>>> geoip2.__path__
['C:\\Users\\Adam\\Envs\\otherlane\\lib\\site-packages\\django\\contrib\\gis\\geoip2']
django geodjango
3个回答
2
投票

由于赞成This module的,支持IPv6和GeoLite2数据库格式版本1.9 django.contrib.gis.geoip2被弃用。

如果你有一个Django <1.9,改用

from django.contrib.gis.geoip import GeoIP

2
投票

我固定通过PIP封装geoip2==2.9.0安装它

pip install geoip2==2.9.0

1
投票

仔细检查您的GEOIP_PATH。而我的我提醒你,Windows需要反斜杠不是正斜杠。

© www.soinside.com 2019 - 2024. All rights reserved.