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,520 points
2,221 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
• 58,100 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, 2020 in Python by MD
• 95,460 points
1,267 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,790 points
1,879 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
• 58,100 points
1,676 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
• 58,100 points
2,368 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
• 58,100 points
723 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP