Zappa
Zappa copied to clipboard
[Migrated] How to include Pango/Cairo to use Weasyprint with my Django app?
Originally from: https://github.com/Miserlou/Zappa/issues/1690 by Brachamul
Context
I have deployed a simple Django app which uses Weasyprint.
Expected Behavior
The app should produce PDF files, upon request.
Actual Behavior
The app prints the following exception: cannot load library 'pango-1.0': pango-1.0: cannot open shared object file: No such file or directory. Additionally, ctypes.util.find_library() did not manage to locate a library called 'pango-1.0'
Weasyprint requires Pango and Cairo, which normally need to be installed on the host machine.
Possible Fix
@Prasengupta has published a github repo, weasyprint_for_awslambda to help with importing Pango and Cairo. Unfortunately, I dont fully understand what needs to be done. He says I should Step 1: Download the zip file from this repository. Step 2: Include your main handler file in the folder and zip it, upload the zip folder to aws lambda.
, but I don't know how to do step 2 with Zappa.
Steps to Reproduce
- Create a Django app which uses Weasyprint to produce a PDF, for example :
weasyprint.HTML("https://www.google.com/").write_pdf()
- Push to AWS
- Witness the error message
Your Environment
- Zappa version used: 0.47.0
- Python version: 3.6
- The output of
pip freeze
: https://justpaste.it/7j2sx
how do u solve this?
@LeonardoFurtado You need to use the docker image and include Pango shared object files during the build step. I was able to use a deep learning library with the shared object files. I will try this Pango shared object in my docker deployment.
Hi there! Unfortunately, this Issue has not seen any activity for at least 90 days. If the Issue is still relevant to the latest version of Zappa, please comment within the next 10 days if you wish to keep it open. Otherwise, it will be automatically closed.
Hi there! Unfortunately, this Issue was automatically closed as it had not seen any activity in at least 100 days. If the Issue is still relevant to the latest version of Zappa, please open a new Issue.