Python error: No handlers could be found for logger “xhtml2pdf”

0 votes

I am converting an HTML to pdf in django function, for this i am using xhtml2pdf pisa module, and the code is

pdf = pisa.CreatePDF(html, file(settings.MEDIA_ROOT+'/tickets_pdf/'+pdfName, "w"))

This code is working and generates pdf but sometime it works and sometime it doesn't work and give error

No handlers could be found for logger “xhtml2pdf”

There is also same question on SO that I have already checked.

No handlers could be found for logger "xhtml2pdf"

But it did not work for me. If my client generates 10 times pdf then at least 4 times it gives this error and in other case it works fine. Is there any solution for this, or i have to generate pdf in other way.

Sep 5, 2018 in Python by bug_seeker
• 15,400 points
576 views

1 answer to this question.

0 votes
The only solution is to define a handler for xhtml2pdf in your settings file, as suggested by provided link.

The reason you get 500 error is because you have defined logger wrong. Check the app logs for errors, check the path to the log file that you have defined in settings.
answered Sep 5, 2018 by Priyaj
• 57,550 points

Related Questions In Python

0 votes
1 answer
+1 vote
1 answer

WindowsError: [Error 126] The specified module could not be found.

Hi@akhtar, You can download the shapely module in ...READ MORE

answered Jul 13 in Python by MD
• 40,740 points
30 views
0 votes
1 answer

how to download and install Django rest framework?

To install Django, you can simply open ...READ MORE

answered Apr 24, 2018 in Python by Christine
• 15,810 points
368 views
0 votes
1 answer
0 votes
1 answer

Host not allowed

Go to your project directory cd project cd project ALLOWED_HOSTS ...READ MORE

answered Aug 9, 2018 in AWS by Priyaj
• 57,550 points
482 views
0 votes
1 answer

'Syntax Error: invalid syntax' for no apparent reason

You're missing a close paren in this ...READ MORE

answered Aug 13, 2018 in Python by Priyaj
• 57,550 points
540 views
0 votes
1 answer

What is the flow control for “continue” in python?

This is the way "continue" statement works! You ...READ MORE

answered Jul 16, 2018 in Python by Priyaj
• 57,550 points
97 views