Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asyncpg and AWS Lambda

I'm trying to use asyncpg with AWS Lambda and got next error when trying to import asyncpg

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

I import python dependencies like at this answer with and without virtual environment.

upd. Found this repo with custom compiled psycopg2 what works good with AWS Lambda but for asyncpg don't found such alternative or instruction on compiling Lambda-friendly asyncpg package.

like image 692
chinskiy Avatar asked Jun 02 '17 14:06

chinskiy


1 Answers

This library has c-bindings and lambda does not play nicely with those. The main way to handle it is to upload the specific library with its bindings precompiled for Linux environments. The main way to is to follow the instructions here and make sure that the library it already compiled in your linux ( or mac I guess ). This would easily happen by just creating a venv and including it as the above guidelines suggest. You can find a similar problem here. In general, this is a common and frameworks like chalice try to find some workarounds.

like image 176
Michael Petychakis Avatar answered Sep 26 '22 20:09

Michael Petychakis