Kozea / WeasyPrint

The awesome document factory
https://weasyprint.org
BSD 3-Clause "New" or "Revised" License
7.16k stars 680 forks source link

Cannot load library pangocairo-1.0 when trying to get WeasyPrint working on AWS Lambda #401

Closed NoneMan closed 6 years ago

NoneMan commented 7 years ago

I like WeasyPrint, and I try to get it working on AWS Lambda. To meet the dependencies, I copied libpango-1.0.so and libpangocairo-1.0.so from Amazon Linux environment, and zipped them with my scirpts. But I got an error message when deploying:

module initialization error: cannot load library pangocairo-1.0: pangocairo-1.0: cannot open shared object file: No such file or directory

And I find this:

#lib/weasyprint/text.py
pango = dlopen(ffi, 'pango-1.0', 'libpango-1.0-0', 'libpango-1.0.so',
               'libpango-1.0.dylib')
pangocairo = dlopen(ffi, 'pangocairo-1.0', 'libpangocairo-1.0-0',
                    'libpangocairo-1.0.so', 'libpangocairo-1.0.dylib')
liZe commented 7 years ago

Thanks for reporting!

Why it can find libpango-1.0.so but cannot find libpangocairo-1.0.so ?

I really don't know how AWS works, I'm afraid I won't be really helpful :cry:. But a reason could be that:

Is there a way to use WeasyPrint on AWS Lambda ?

I don't know… @sparrovv is using EC2 in #223, maybe it could help to contact him.

liZe commented 7 years ago

@NoneMan can I close this issue?

polakala commented 7 years ago

I am seeing the same problem when creating aws lambda function for weasyprint. Did anyone resolved this?

y0rd4nis commented 7 years ago

I'm running WeasyPrint on AWS Lambda, the first run of my lambda function fails because it does not find some pango libs, I copied libpango-1.0.so.0.2800.1, libpangocairo-1.0.so.0.2800.1 and libpangoft2-1.0.so.0.2800.1 from Amazon Linux to the root of my lambda function package, I renamed the firt two .so to pango-1.0 and pangocairo-1.0 and now it is working.

I have had some problems with gif images that can be seen in #428 and my comment.

liZe commented 7 years ago

Is anyone interested in adding an "AWS" section to the documentation?

liZe commented 6 years ago

Closing. See #428 about images and documentation.

Prasengupta commented 6 years ago

Guys below is the git link where you can download the weasy print library which works with AWS lambda.

https://github.com/Prasengupta/weasyprint_for_awslambda

These libraries are picked from Amazon Linux is equal to centOS. which may not working in your local windows machine but works in aws lambda function for sure Please raise a ticket if you face any issues.

procal commented 5 years ago

Thanks for the lambda support @Prasengupta @liZe . I've tried uploading my WEasyPrint lambda function with your package directory @Prasengupta but I'm still getting an import error. I've also tried my own zip of packages from pip and imported the3 pango files directly from an Amazon Linux instance (they're still using pango-1.28.1 anyway) but without any success.

Removed the WEasyPrint import and execution of the lambda function is fine. I'm out of ideas now unfortunately. Can you tell me how you pulled that zip file together originally? Were they all pulled from Amazon Linux?

Thanks so much, Ed

Prasengupta commented 5 years ago

Hi @procal

I think you're trying to execute in python3 which the published package is not supported. Please check with python27

I've searched those files in the amazon Linux instance by the command and able to get them. But I don't remember the path.