pythonaws-lambdawhois

Error while importing python-whois on AWS Lambda


I'm trying to run a script that uses python-whois and I'm having an error. This was previously imported locally using "pip3 install python-whois -t ." and then uploaded to the zip file into AWS Lambda. I'm using Python v3.12

import json
import whois


def lambda_handler(event, context):    
    
    return {
        'statusCode': 200,
        'body': event
    }

The error message:

[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': No module named 'imp'
Traceback (most recent call last):

Solution

  • I found the answer to my question.

    Presently (28 January 2024), the "imp" library is unavailable on AWS Lambda Python v3.12. I moved to v3.11, and it worked just fine.