import pygeoip
gi = pygeoip.GeoIP('GeoLiteCity.dat')
response = gi.record_by_addr(ip)
我正常导入库,路径也正确,想要用 Python 的 pygeoip 库通过 ip 获取经纬,然后给百度地图,在页面显示,结果在形成对象这儿卡住了
各位大佬,帮吗看一下是啥情况?
分割线
File "/usr/local/lib/python2.7/site-packages/pygeoip/
__init__.py", line 118, in __init__
self._fp = codecs.open(filename, 'rb', ENCODING)
File "/usr/local/lib/python2.7/
codecs.py", line 896, in open
------------if mode[:1] not in set('rwa'):
--------------mode = 'r' + mode
Open an interactive python shell in this frame if 'b' not in mode:
------------# Force opening of the file in binary mode
------------mode = mode + 'b'
----file = __builtin__.open(filename, mode, buffering) # 报这个错误!!!
----if encoding is None:
--------return file
----info = lookup(encoding)
----srw = StreamReaderWriter(file, info.streamreader, info.streamwriter, errors)
----# Add attributes to simplify introspection
IOError: [Errno 2] No such file or directory: 'GeoLiteCity.dat'
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
https://www.v2ex.com/t/474450
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.