I'm developing a python function for AWS lambda.
My function works locally, with:
python-lambda-local -f handler app.py event.json -t 30
However, when I deploy it in AWS Lambda, (with a zip file with all dependencies), it seems the objectify lib is not loaded. Error message:
Unable to import module 'app': cannot import name 'objectify'
This is a snippet of my function:
# -*- coding: utf-8 -*-
import sys
import logging
import env_config
import pymysql
import traceback
import json
import requests
#from lxml import objectify
import lxml.objectify
import lxml.etree
1 Answer 1
Lxml uses code compiled in C. You need to precompile the library in the same environment that Lambda runs. Read this to understand more: https://www.azavea.com/blog/2016/06/27/using-python-lxml-amazon-lambda/
This kind person already did the job for you. Just download the precompiled library and replace in your Lambda package: https://github.com/JFox/aws-lambda-lxml