I'm trying run this code adapted from this answer.
from datetime import datetime
from pytz import timezone
import pytz
def lambda_handler(event, context):
date_format='%m/%d/%Y %H:%M:%S %Z'
date = datetime.now(tz=pytz.utc)
print('Current date & time is:', date.strftime(date_format))
date = date.astimezone(timezone('US/Pacific'))
print('Local date & time is :', date.strftime(date_format))
I am running on AWS Lambda. I am getting this error:
Response:
{
"errorMessage": "Unable to import module 'lambda_function': No module named 'pytz'",
"errorType": "Runtime.ImportModuleError"
}
How can I fix this, using only imports available in AWS Lambda? I want to keep the code very minimalistic so that it can be copy-pasted directly into the AWS Console, without having to add instructions on how to setup packages etc.