0

I worked on Python 3.8 script that includes sqlite3 and serial. It worked well when running them on barebone Raspi OS. However, when I tried to use them on containerized lambda, I get these errors

lambda_runtime.py:141,Failed to import handler function "main.function_handler" due to exception: No module named 'serial'

and

lambda_runtime.py:141,Failed to import handler function "main.function_handler" due to exception: No module named '_sqlite3'

The question is how do I import these modules along with my code? It seems absurd to be that greengrass sdk uses sqlite3 but I can't use them in my own lambda function

Any helps? I can provide more details if needed

ItsNickkk
  • 28
  • 5

1 Answers1

1

Fixed Serial by importing serial along with my lambda code

Since my RaspiOS is running on Python 3.9, I had to downgrade to Python 3.8 by compiling and installing 3.8 myself. This is the full script that i used to install 3.8 and enable sqlite3 on default. Note the --enable-loadable-sqlite-extensions flag on configure, i believe that's what solved the issue i had up there

wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tar.xz
tar xf Python-3.8.0.tar.xz
cd Python-3.8.0
./configure --enable-loadable-sqlite-extensions --enable-optimizations --prefix=/usr
make
sudo make altinstall
cd ..
sudo rm -r Python-3.8.0
rm Python-3.8.0.tar.xz
ItsNickkk
  • 28
  • 5