4

在努力为 Django 项目正确安装 GeoIp 之后,我终于似乎已经通过带有 brew 的通用 geoip 正确安装了它。

不幸的是,在 shell 中尝试它时,我收到以下错误:

>>> from django.contrib.gis.utils.geoip import GeoIP
>>> g = GeoIP()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/gis/utils/geoip.py", line 193, in __init__
raise TypeError('Invalid path type: %s' % type(path).__name__)

TypeError:无效的路径类型:元组

我一直在尝试正确安装 GeoIP 大约七个小时,因此非常感谢您对这个最新错误的任何见解。

4

1 回答 1

4

If you really have a comma in there, then you are setting GEOIP_PATH to a tuple and not a string, which would explain the error. If this is the case, simply remove the comma:

# settings.py

import os

BASE_DIR = os.path.abspath(os.path.dirname(__file__))
GEOIP_PATH = os.path.join(BASE_DIR, 'geoip')
于 2012-05-25T03:27:03.503 回答