Fix OSError: No wkhtmltopdf executable found in Win 10 for pdfkit Beginner – Python pdfkit Tutorial

By | July 30, 2019

When you start to use python pdfkit library to convert a html to pdf in win 10, you may find OSError: No wkhtmltopdf executable found. In this tutorial, we will introduce you how to fix this error.

No wkhtmltopdf executable found error

If you have read how to install wkhtmltopdf in here.

https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf

You may notice, if the system is window system, you shoud add wkhtmltopdf folder to system environment. However, i will tell you this method does not work.

add wkhtmltopdf to system environment

How to fix this error?

Find the installation path of wkhtmltopdf.exe

As to us, this path is: C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe

Set pdfkit configuration

config = pdfkit.configuration(wkhtmltopdf='C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe')

Convert html to pdf

pdfkit.from_url('https://www.tutorialexample.com', 'out-test.pdf', configuration=config)

Then you will find this error is fixed.

2 thoughts on “Fix OSError: No wkhtmltopdf executable found in Win 10 for pdfkit Beginner – Python pdfkit Tutorial

    1. admin Post author

      I have checked your question:
      1. When I add wkhtmltopdf configuration the page can’t load into the browser.
      2. when I remove wkhtmltopdf configuration from my app then my all routes work fine only when i click on the pdf then its give in error.
      It means your application may be running pdfkit when loading home page, which is not a good way to convert html to pdf. You should check your application to avoid to run pdfkit when loading pages.
      Meanwhile, your app can not load pdfkit into the browser, you should write a test page to test whether pdfkit can be loaded and run by brower.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *