sdispater / pendulum

Python datetimes made easy
https://pendulum.eustace.io
MIT License
6.24k stars 387 forks source link

Pendulum with AWS Lambda, cannot use the module. #465

Open markotitel opened 4 years ago

markotitel commented 4 years ago

Issue

I've tried to find help on Reditt Python sub before posting an issue here. I have a simple lambda function where I need to use Pendulum package.

import pendulum
def lambda_handler(event, context):
    print(pendulum.now())

The error I get is "errorMessage": "module 'pendulum' has no attribute 'now'"

This code works fine locally.

import pendulum
print(pendulum.now())

I've tried to do maximum debugging I knew. These are the results of it. Locally:

import pendulum
print(pendulum)

OUTPUT: <module 'pendulum' from '/path/archive_date/.package/pendulum/__init__.py'>

On Lambda output is: OUTPUT: <module 'pendulum' (namespace)>

I still guess that I am doing something wrong here.

richard-scott commented 3 years ago

I've just seen this on a Raspberry Pi and got round it with this:

$ pip install --no-binary=pendulum pendulum