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.

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('', 'out-test.pdf', configuration=config)

Then you will find this error is fixed.