Module initialization error

aws

#1

I am using virtualenv and serverless-python-requirements for my Python deployment in AWS Lambda using serverless framework. But after upload when i am calling the function it is giving “module initialization error: [Errno 22] Invalid argument” error.


#2

@himadri Can you paste a longer portion of the stack trace? Hard to tell what the issue is there.


#3

Hi,

Thanks for replying. But I am not getting any other details in CloudWatch.


#4

Can you please guide what to do.


#5

There should be additional logs in CloudWatch or something. If not, you could paste your serverless.yml and function code in an attempt to reproduce?


#6

Here is my serverless.yml file https://gist.github.com/himadriganguly/f9571c09a3c01c79ebf920034f5e5e55


#7

Since you’re zipping your dependencies, do you have the line to unzip them at the top of your handler.py module?

# handler.py

import unzip_requirements

... rest of code ...

It’s going to be tough to debug without a longer stack trace or your function code.


#8

Yes included that like this import unzip_requirements.


#9

So what can be the problem? What other things should I check?


#10

Also checked my Python version under virtualenv which is Python 3.6.2.


#11

Before using Serverless when I am manually creating the zip file with all the python modules in the root path and uploading it to Lambda it is working fine. To automate the process I am using the Serverless Framework and now I got into this problem. :disappointed: