Can't create pdf using python PDFKIT Error : " No wkhtmltopdf executable found:"

Solution 1:

The following should work without needing to modify the windows environment variables:

import pdfkit
path_wkhtmltopdf = r'C:\Program Files (x86)\wkhtmltopdf\bin\wkhtmltopdf.exe'
config = pdfkit.configuration(wkhtmltopdf=path_wkhtmltopdf)
pdfkit.from_url("http://google.com", "out.pdf", configuration=config)

Assuming the path is correct of course (e.g. in my case it is r'C:\Program Files (x86)\wkhtmltopdf\bin\wkhtmltopdf.exe').

Solution 2:

Please install wkhtmltopdf using,

sudo apt install -y wkhtmltopdf

for windows machine install it from below link, http://wkhtmltopdf.org/downloads.html

and you need to add wkhtmltopdf path into environment variables