I've been coming up a brick wall with getting AWS Lambda to run my code. I'm following https://robertorocha.info/setting-up-a-selenium-web-scraper-on-aws-lambda-with-python/. Trying to get a web scraper working on AWS Lambda that needs selenium and headless chrome. I will say I'm using windows rather than linux/mac.
The tutorial uses lambci to replicate the environment of AWS Lambda and to install linux dependancies. When making the final zip file for uploading to S3 for use with lambda.
When I put the python script into the folder /src as in the tutorial says to do, it wont import the module lambda_function. When I put the python file by itself in the zip it seems to run but this error message comes up, I have changed the environment variable in lambda so that will see lambda_function.py.
{
"errorMessage": "Unable to import module 'lambda_function': cannot import name 'WinDLL' from 'ctypes' (/var/lang/lib/python3.7/ctypes/__init__.py)",
"errorType": "Runtime.ImportModuleError"
}
Here are my requirements:
boto3==1.6.18
botocore==1.9.18
selenium==3.141.0
chromedriver-install==1.0.3
numpy==1.18.2
requests==2.23.0
Folder structure of the zip file to upload to S3.
lambda_function.py
/lib
/bin
When I run make docker-run
, the code runs fine with no error messages. For some reason I was getting an error message when running the makefile code that builds the lambda package. I did this part manually essentially moving folders and zipping the libraries, python file up. I'm wondering if that is where my error is. I've read somewhere that numpy doesnt integrate well with AWS Lambda, but it uses the linux .whl file when building the image and its not mentioned in the error message.
I've tried googling the error message and there's not much about it to be honest! I'm not actually sure what it means.
Any help would be appreciated. If you need me to post my python code that's fine, but as I said,
make docker-run
worked fine without error so I'm not sure it's the code per se that is the problem.
Appreciate any help even if it's just to get a handle on what the error message might be about.