Asyncpg and AWS Lambda

I am trying to use asyncpg with AWS Lambda and got the following error while trying to import asyncpg

 Unable to import module 'handler': No module named asyncpg.protocol.protocol' 

I import python dependencies such as this one with and without virtual environment.

update This repo was found with a custom compiled psycopg2 , which works well with AWS Lambda, but for asyncpg no such alternative or compilation instructions for Lambda-friendly asyncpg .

+5
source share
1 answer

This library has c-bindings, and lambda doesn't play well with them. The main way to handle this is to load a specific library with its bindings precompiled for Linux environments. The main way is to follow the instructions here and make sure that the library that it already compiled on your Linux (or, I think, Mac). This will easily happen by simply creating venv and including it in accordance with the above recommendations. You can find a similar problem here . In general, these are common frameworks such as chalice try to find some workarounds.

+3
source

Source: https://habr.com/ru/post/1268477/


All Articles