Using sqlobject. When I import the module I get a unable to load module error when running lambda local or remote. The module is installed and if I get a command line python3 interpreter and import the module it imports just fine.
How do I get 3rd party modules installed so they work with both lambda local and lambda remote?
Code could not be simpler:
import sqlobject
Answering my own question... These are instructions for Python 3.
First start with an empty environment, mine was called cycles.
Create a new lambda function:
Your folder structure now looks like this:
There will be two folders with the same name (a bit confusing - ask AWS not me).
Right button click on the top most folder with your lambda function name and select "Open terminal here". This gets you command line.
No need to use sudo, just install the packages you need. Install your packages into that folder:
python3 -m pip install --target=./ sqlobject
IMPORTANT You need to install the packages in that top folder that you opens a terminal from. See the part of the pip install line that says:
--target=./
that makes sure the packages get installed in the right folder that lambda can use. If you use the standard pip install:
python3 -m pip install sqlobject
You packages will be installed in the wrong place.
Your folder structure should look like this with the new added packeges installed:
You can see the code to the right...it ran fine with the sqlobject package installed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With