Zappa icon indicating copy to clipboard operation
Zappa copied to clipboard

[Migrated] How to include Pango/Cairo to use Weasyprint with my Django app?

Open jneves opened this issue 4 years ago • 2 comments

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

  1. Create a Django app which uses Weasyprint to produce a PDF, for example : weasyprint.HTML("https://www.google.com/").write_pdf()
  2. Push to AWS
  3. 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

jneves avatar Feb 20 '21 12:02 jneves

how do u solve this?

LeonardoFurtado avatar May 04 '23 15:05 LeonardoFurtado

@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.

souravjamwal77 avatar May 05 '23 09:05 souravjamwal77

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.

github-actions[bot] avatar Apr 03 '24 15:04 github-actions[bot]

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.

github-actions[bot] avatar Apr 13 '24 17:04 github-actions[bot]