I am trying to create an AWS lambda function using Python. Instead of an inline function I want a create a zip deployment package and then upload it in my AWS environment. I have my source code in test.py file and other dependencies like numpy, sklearn and so on in the same folder as my source code is.
I am facing an error when I test my lambda function.
Unable to import module 'test': No module named 'sklearn.__check_build._check_build' ___________________________________________________________________________ Contents of /var/task/sklearn/__check_build: setup.py
__pycache__ _check_build.cp36-win_amd64.pyd __init__.py ___________________________________________________________________________ It seems that scikit-learn has not been built correctly. If you have installed scikit-learn from source, please do not forget to build the package before using it: runpython setup.py install
ormake
in the source directory. If you have used an installer, please check that it is suited for your Python version, your operating system and your platform.
Here is my python source code which resides in test.py
from sklearn.model_selection import train_test_split
print('Loading function')
def lambda_handler(event, context):
#print("Received event: " + json.dumps(event, indent=2))
print("value1 is " + event['key1'])
print("value2 is " + event['key2'])
print("value3 is " + event['key3'])
return event
I am facing a similar issue if I import numpy in my source code. (cannot import multiarray)
I am installing every library using pip install numpy/scikit-learn -t /path/to/mydir/
.
Here is the folder structure after I use pip install commands
Kindly help me resolve the issue. Thanks !!