Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pillow Import Issue when using custom FPDF2 Layer in AWS Lambda #1037

Closed
dpar21 opened this issue Nov 27, 2023 · 4 comments
Closed

Pillow Import Issue when using custom FPDF2 Layer in AWS Lambda #1037

dpar21 opened this issue Nov 27, 2023 · 4 comments
Labels

Comments

@dpar21
Copy link

dpar21 commented Nov 27, 2023

Hello,

I am currently attempting to use a custom FPDF2 layer for a Python3.8 runtime AWS Lambda function (I have tried Python3.9 and 3.10 as well) but am running into a Pillow not found issue.

Here is the exact warning + error I am running into:

Warning:
/opt/python/lib/python3.8/site-packages/fpdf/fpdf.py:33: UserWarning: Pillow could not be imported - fpdf2 will not be able to add any image

Error:
File "/opt/python/lib/python3.8/site-packages/fpdf/image_parsing.py", line 116, in get_img_info\n raise EnvironmentError("Pillow not available - fpdf2 cannot insert images")\n"

Based on previous posts and significant online research it seems like Pillow should be found even when I create a custom FPDF2 layer for AWS Lambda. I install both as well when building the layer to ensure that they are available prior to adding the layer to AWS Lambda.

Would appreciate any help or insight!

@dpar21 dpar21 changed the title Pillow Import Issue when using custom FPDF2 Layer in AWS Lambda. Pillow Import Issue when using custom FPDF2 Layer in AWS Lambda Nov 27, 2023
@Lucas-C
Copy link
Member

Lucas-C commented Nov 28, 2023

Hi and welcome @dpar21

Have you checked our documentation on how to use fpdf2 in AWS lambdas?
https://py-pdf.github.io/fpdf2/UsageInWebAPI.html#aws-lambda

There is a subsection named "Creating & uploading a lambda layer" that provides an example of creating a lambda layer including all required dependencies for fpdf2 to function properly.

Does that solve your problem?

@dpar21
Copy link
Author

dpar21 commented Nov 28, 2023

Hello @Lucas-C and thank you for the link on how to create an AWS Lambda layer for FPDF2. Apologies, I was unable to find this in the documentation myself so I really appreciate the clarification.

I definitely think I was incorrectly creating the Lambda layer so I will be sure to follow the instructions in the documentation and get back to this thread if I still continue to have issues.

@dpar21
Copy link
Author

dpar21 commented Nov 28, 2023

Thank you @Lucas-C! I simply had to remove the PIL and Pillow dependency folders after installing fpdf2 and then use a distinct Pillow layer as stated in the documentation.

@dpar21 dpar21 closed this as completed Nov 28, 2023
@Lucas-C
Copy link
Member

Lucas-C commented Nov 28, 2023

Thank you @Lucas-C! I simply had to remove the PIL and Pillow dependency folders after installing fpdf2 and then use a distinct Pillow layer as stated in the documentation.

Glad that you found a solution!
Good job 😊👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants