Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Deployment Package with SKLEARN, PANDAS and NUMPY issue?

I am a newbie on the AWS & Python and trying to implement a simple ML recommendation system using AWS Lambda function for self-learning. I am stuck on the packaging the combination of sklearn, numpy and pandas. If combined any two lib means (Pandas and Numpy) or (Numpy and Skype) is working fine and deploy perfectly. Because I am using ML system then i need sklearn (scipy and pandas and numpy) which cannot work and getting this error on aws lambda test. What I have done so far : my deployment package from within a python3.6 virtualenv, rather than directly from the host machine. (have python3.6, virtualenv and awscli already installed/configured, and that your lambda function code is in the ~/lambda_code directory):

  1. cd ~ (We'll build the virtualenv in the home directory)

  2. virtualenv venv --python=python3.6 (Create the virtual environment)

  3. source venv/bin/activate (Activate the virtual environment)

  4. pip install sklearn, pandas, numpy

  5. cp -r ~/venv/lib/python3.6/site-packages/* ~/lambda_code (Copy all installed packages into root level of lambda_code directory. This will include a few unnecessary files, but you can remove those yourself if needed)

  6. cd ~/lambda_code

  7. zip -r9 ~/package.zip . (Zip up the lambda package)

  8. aws lambda update-function-code --function-name my_lambda_function --zip-file fileb://~/package.zip (Upload to AWS)

after that getting this error:

**"errorMessage": "Unable to import module 'index'"**

and

START RequestId: 0e9be841-2816-11e8-a8ab-636c0eb502bf Version: $LATEST
Unable to import module 'index': **Missing required dependencies ['numpy']**

END RequestId: 0e9be841-2816-11e8-a8ab-636c0eb502bf
REPORT RequestId: 0e9be841-2816-11e8-a8ab-636c0eb502bf  Duration: 0.90 ms   Billed Duration: 100 ms     Memory Size: 128 MB Max Memory Used: 33 MB  

I have tried this on EC2 instance as well but did not a success.I did the google and read multiple blogs and solution but not worked. Please help me out on this.

like image 350
Vinay Mishra Avatar asked Mar 14 '18 11:03

Vinay Mishra


People also ask

What is the use of pandas NumPy and Scikit-learn in Python?

It is an open source module of Python which provides fast mathematical computation on arrays and matrices. Since, arrays and matrices are an essential part of the Machine Learning ecosystem, NumPy along with Machine Learning modules like Scikit-learn, Pandas, Matplotlib, TensorFlow, etc.

Does Scikit-learn include NumPy?

Most of scikit-learn assumes data is in NumPy arrays or SciPy sparse matrices of a single numeric dtype.

What is pandas and Sklearn in Python?

This module provides a bridge between Scikit-Learn's machine learning methods and pandas-style Data Frames. In particular, it provides a way to map DataFrame columns to transformations, which are later recombined into features.


1 Answers

u are using python 3.6 . so pip3 install numpy should be used, make a try .

like image 180
Go Go Gadget 2 Avatar answered Oct 19 '22 20:10

Go Go Gadget 2