"errorMessage": "Module initialization error"

Using Python I followed and when it came to the Test

following error appeared:

{
  "errorMessage": "module initialization error"
}

      

What could I have done wrong?

+3


source to share


2 answers


You don't need environment variables. Just keep it simple.

from __future__ import print_function

import os
from datetime import datetime
from urllib2 import urlopen


def lambda_handler(event, context):
    url = 'https://www.google.com' # change it with your own
    print('Checking {} at {}...'.format(url, datetime.utcnow()))
    html = urlopen(url).read()
    # do some processing
    return html

      

Here's another simple example.



from __future__ import print_function


def lambda_handler(event, context):
    first = event.get('first', 0)
    second = event.get('second', 0)
    sum = first + second
    return sum

      

Here is an example event that will be used to call this lambda. you can set up an event from the Lambda frontend. (or google it)

{
  "first": 10,
  "second": 23
}

      

0


source


In my case, I missed adding logging_config.ini

the lambda to the function.

I think you would run into a similar error when the lambda function does not find the file or package it references.



Thanks to the new cloud9 IDE integration, I was able to build it on the fly.

0


source







All Articles