首页 > 解决方案 > Cannot use python-geoip with AWS Lambda

问题描述

Python-Geoip is a small package that allows free offline use of the MaxMind country database. It works fine locally, but I cannot get it working within AWS Lambda.

I created a deployment package with requests, geoip and geoip-geolite2, but I am getting the following error message:

"errorMessage": "Unable to import module 'uploadXmlLog'"

If I comment out requests I get the error message:

"errorMessage": "Cannot use packaged database \"geolite2\" because package \"_geoip_geolite2\" is not available. It's provided by PyPI package \"python-geoip-geolite2\""

Using requests without geoip works fine.

How can I resolve this?

Deployment package contents

标签: pythonaws-lambdageoip

解决方案


我的错,对不起。一些内部文件夹的内容未包含在部署包中。需要使用 'zip -r ...' 创建开发包。顺便说一句,由于 geoip db 部署包增加到 ~18 Mb 并且 AWS 不允许您在线编辑 python 文件。但工作正常。


推荐阅读