简体   繁体   English

在CentOs服务器上导入GeoIP时出现python错误

[英]in python error while importing GeoIP on CentOs server

I am using Django, and when I am using the geoip package or importing GeoIP I am getting the following error on centos, while it is working well on ubuntu 12.04. 我正在使用Django,并且当我使用geoip软件包或导入GeoIP时,在ubuntu 12.04上运行良好时,在centos上收到以下错误。

The error is as follows 错误如下

 from django.contrib.gis.utils.geoip import GeoIP
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/site-packages/django/contrib/gis/utils/geoip.py", line 67, in <module>
    'Try setting GEOIP_LIBRARY_PATH in your settings.' % lib_name)
django.contrib.gis.utils.geoip.GeoIPException: Could not find the GeoIP library (tried "GeoIP"). Try setting GEOIP_LIBRARY_PATH in your settings.

please try to help me out, I can't go further without this. 请尝试帮助我,没有这个我无法走得更远。

trying doing this on both of your systems: 尝试在两个系统上都这样做:

$ echo $GEOIP_LIBRARY_PATH

and compare the output. 并比较输出。 From the error message, it sounds like you will get a directory path on Ubuntu, and make sure the same path is set up on CentOS, like so (on the centOS system): 从错误消息中,听起来您将在Ubuntu上获得目录路径,并确保在CentOS上设置了相同的路径,例如在centOS系统上:

$ export GEOIP_LIBRARY_PATH=$GEOIP_LIBRARY_PATH:<path returned from Ubuntu system>

The django geoip code is using the MaxMind free geoip data that is distributed in the form of a proprietary file-based 'database'. django geoip代码使用的是MaxMind免费geoip数据,该数据以基于文件的专有“数据库”的形式分发。 You're probably missing the rpm package for that, after which you can locate the shared library it provides & set the GEOIP_LIBRARY_PATH to point to it. 您可能为此缺少rpm包,之后您可以找到它提供的共享库并设置GEOIP_LIBRARY_PATH指向它。 Looks like there's both an example of setting the path and some packages for CentOS as well. 看起来既有设置路径的示例,有CentOS的一些软件包

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

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