Prasengupta / weasyprint_for_awslambda

Supporting WeasyPrint in AWS Lambda
23 stars 7 forks source link

Does it work for Python 3.x runtimes? #3

Closed JoaoCarabetta closed 3 years ago

JoaoCarabetta commented 5 years ago

I got the following error when I ran for python 3.6 and 3.7

{
  "errorMessage": "Unable to import module 'lambda_function': dynamic module does not define module export function (PyInit__cffi_backend)",
  "errorType": "Runtime.ImportModuleError"
}

My main handler file just imports the weasyprint module.

But, it worked with Python 2.7.

Is it possible to use Python 3.x runtimes?

Prasengupta commented 5 years ago

HI Jaoa,

I haven't tried in python 3.x runtime. let me know if you really needed in 3.x will try and let you know.

mojimi commented 5 years ago

HI Jaoa,

I haven't tried in python 3.x runtime. let me know if you really needed in 3.x will try and let you know.

Yes please! I find it very much needed, or at least post what we need to change/do for this to work.

Also did you ever get .JPEG and .GIF images to work? these depend on gdk-pixbuff-2.0 and I think they don't work very well on lambda

HugoBarreto commented 5 years ago

HI Jaoa,

I haven't tried in python 3.x runtime. let me know if you really needed in 3.x will try and let you know.

It would be great!! You could also document your process, so we are able to do it ourselves in next releases

Prasengupta commented 5 years ago

Hello, all this library isn't working in python 3.6 version. I think I need to debug the issue

@JoaoCarabetta @mojimi @HugoBarreto

Prasengupta commented 5 years ago

HI Jaoa, I haven't tried in python 3.x runtime. let me know if you really needed in 3.x will try and let you know.

It would be great!! You could also document your process, so we are able to do it ourselves in next releases

Hi I wonder what else process you required me to do. If you know how to deploy the lambda ?

Just the same thing while you upload the lambda you will install the dependencies within the folder. same with it just unzip and place the folder in your lambda project.

There is no big process behind it

HugoBarreto commented 5 years ago

@Prasengupta. I do know how to deploy lambda. Actually, i've been using your version of weasyprint to generate some reports automatically and it's been amazing, thanks for that!

However, on my own server, i'm using the latest version of weasyprint and when it renders a pdf, it is slightly different from what i got with lambda. In the end, what works on one place, might not work in the other and vice-versa, that's why i'd like to get the latest version of weasyprint to work in lambda.

If it is too complicated, i might just create a lambda image on docker to execute my function and interate faster, but this is my last resource for now.

Thanks again! Cheers

Prasengupta commented 5 years ago

@HugoBarreto

Thanks for your comments, Ok I thought you're asking the process of deploying the lambda. Ok now I got you would like to know how to have the packages

See what actually I have done the weasyprint provides the library which works in windows and might be other OS also. But we are running the library in the AWS lambda which runs in AWS Linux Operating system. So load the actual weasyprint library files to the lambda and run, it asks for few files missing search those files in the AWS Oracle Linux if available or launch the instance in AWS and get those files and place them in the weasy print folder and upload to lambda again and repeat.

NinjaChristopher commented 5 years ago

I would really like to make WeasyPrint work on Python 3 with AWS Lambda. I'm not too experienced with AWS Lambda and I don't really understand how I would do this:

See what actually I have done the weasyprint provides the library which works in windows and might be other OS also. But we are running the library in the AWS lambda which runs in AWS Linux Operating system. So load the actual weasyprint library files to the lambda and run, it asks for few files missing search those files in the AWS Oracle Linux if available or launch the instance in AWS and get those files and place them in the weasy print folder and upload to lambda again and repeat.

Like where do I get which files and which folder do I paste them in?

Currently I'm getting the following error:

OSError at / 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'

Would anyone be able to provide me with some guidance on how to make it work?

ParthMahawar commented 5 years ago

I would really like to make WeasyPrint work on Python 3 with AWS Lambda. I'm not too experienced with AWS Lambda and I don't really understand how I would do this:

See what actually I have done the weasyprint provides the library which works in windows and might be other OS also. But we are running the library in the AWS lambda which runs in AWS Linux Operating system. So load the actual weasyprint library files to the lambda and run, it asks for few files missing search those files in the AWS Oracle Linux if available or launch the instance in AWS and get those files and place them in the weasy print folder and upload to lambda again and repeat.

Like where do I get which files and which folder do I paste them in?

Currently I'm getting the following error:

OSError at / 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'

Would anyone be able to provide me with some guidance on how to make it work?

I've been having the exact same issue as well. I think I'm just going to try and get this done in Python 2.

Prasengupta commented 5 years ago

Hi

You will get those files in Linux operating system I have done the same thing.

On Fri, Jul 12, 2019 at 12:30 PM NinjaChristopher notifications@github.com wrote:

I would really like to make WeasyPrint work on Python 3 with AWS Lambda. I'm not too experienced with AWS Lambda and I don't really understand how I would do this:

See what actually I have done the weasyprint provides the library which works in windows and might be other OS also. But we are running the library in the AWS lambda which runs in AWS Linux Operating system. So load the actual weasyprint library files to the lambda and run, it asks for few files missing search those files in the AWS Oracle Linux if available or launch the instance in AWS and get those files and place them in the weasy print folder and upload to lambda again and repeat.

Like where do I get which files and which folder do I paste them in?

Currently I'm getting the following error:

OSError at / 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'

Would anyone be able to provide me with some guidance on how to make it work?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Prasengupta/weasyprint_for_awslambda/issues/3?email_source=notifications&email_token=AGZYAE2H3X36JFPVP4LNNZLP7AT2VA5CNFSM4GXQ3OS2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZY4GPY#issuecomment-510772031, or mute the thread https://github.com/notifications/unsubscribe-auth/AGZYAEYMWC5RVKHFLLSFZL3P7AT2VANCNFSM4GXQ3OSQ .

mojimi commented 5 years ago

Those files need to be extracted from a amazon linux 2 ami, I have tried before but its somewhat complicated if you have no experience in this area.