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'
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'

1