EC2服务器中的Python Geoip2 maxminddb.reader错误

EC2服务器中的Python Geoip2 maxminddb.reader错误,python,python-3.x,django,geoip,maxmind,Python,Python 3.x,Django,Geoip,Maxmind,您好,我面临以下代码的问题 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.

您好,我面临以下代码的问题

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
回溯(最近一次呼叫最后一次):
文件“test.py”,第2行,在
导入geoip2.0数据库
文件“/var/www/html/geo/test/lib/python3.5/site packages/geoip2/database.py”,第10行,在
导入maxminddb
文件“/var/www/html/geo/test/lib/python3.5/site packages/maxminddb/__init__.py”,第5行,在
导入maxminddb.reader
文件“/var/www/html/geo/test/lib/python3.5/site packages/maxminddb/reader.py”,第36行
_缓冲区:联合[字节,文件缓冲区,“mmap.mmap”]
^
SyntaxError:无效语法
软件包和版本 Python 3.5.2 aiohttp==3.6.2 异步超时==3.0.1 属性==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 包装资源==0.0.0 请求==2.24.0 simplegeoip2==1.0.2 键入扩展==3.7.4.3 urllib3==1.25.10
yarl==1.5.1

您是否在本地计算机中使用python 3.7+

在python 3.5中不支持注释变量类型

比如错误exc信息

 _buffer: Union[bytes, FileBuffer, "mmap.mmap"]

在ec2服务器中使用python 3.7+,一切正常。

在我更改了 geoip2==2.9.0
maxminddb==1.4.1

我已经在Python2.7中使用了这个geoip2。那个时候我并没有遇到任何问题,我无法在服务器中修改Python版本。可以将geoip2与Python 3.5.2一起使用吗