您好,我遇到以下代码的问题。
PS:它在我的本地计算机上运行良好,但在服务器中面临问题。
import geoip2.database
def get_geo_city_from_ip(ip="103.148.20.109"):
try:
reader = geoip2.database.Reader('GeoLite2-City.mmdb')
response = reader.city(ip)
city=response.city.name
reader.close()
return city
except Exception as e:
return None
a = get_geo_city_from_ip()
print("City ####",a)
错误
Traceback (most recent call last):
File "test.py", line 2, in <module>
import geoip2.database
File "/var/www/html/geo/test/lib/python3.5/site-packages/geoip2/database.py", line 10, in <module>
import maxminddb
File "/var/www/html/geo/test/lib/python3.5/site-packages/maxminddb/__init__.py", line 5, in <module>
import maxminddb.reader
File "/var/www/html/geo/test/lib/python3.5/site-packages/maxminddb/reader.py", line 36
_buffer: Union[bytes, FileBuffer, "mmap.mmap"]
^
SyntaxError: invalid syntax
软件包和版本 Python 3.5.2 aiohttp==3.6.2 async-timeout==3.0.1 attrs==20.2.0 certifi==2020.6.20 chardet==3.0.4 geoip2==4.0.2 idna==2.10 idna -ssl==1.1.0 maxminddb==2.0.2 multidict==4.7.6 pkg-resources==0.0.0 requests==2.24.0 simplegeoip2==1.0.2 Typing-extensions==3.7.4.3 urllib3== 1.25.10 亚尔==1.5.1
HUX布斯
万千封印
相关分类