简体   繁体   English

Django GeoIP 错误; 无效的路径类型

[英]Django GeoIP Error; invalid path type

After struggling to get GeoIp installed properly for a Django project, I finally appear to have installed it properly via universal geoip with brew.在努力为 Django 项目正确安装 GeoIp 之后,我终于似乎通过带有 brew 的通用 geoip 正确安装了它。

Unfortunately, when trying it out in the shell, I'm receiving the following error:不幸的是,在 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: Invalid path type: tuple类型错误:无效的路径类型:元组

I've been trying to properly install GeoIP for about seven hours so any insight into this latest error would be very much appreciated.我一直在尝试正确安装 GeoIP 大约七个小时,因此非常感谢对这个最新错误的任何见解。

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.如果那里确实有逗号,那么您将 GEOIP_PATH 设置为元组而不是字符串,这将解释错误。 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')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM