Can't create pdf using python PDFKIT Error : " No wkhtmltopdf executable found:"
The following should work without needing to modify the windows environment variables:
import pdfkitpath_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').
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
IOError: 'No wkhtmltopdf executable found'
Make sure that you have wkhtmltopdf in your $PATH or set via custom configuration. where wkhtmltopdf
in Windows or which wkhtmltopdf
on Linux should return actual path to binary.
Adding this configuration line worked for me:
config = pdfkit.configuration(wkhtmltopdf="C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe")pdfkit.from_string(html, 'MyPDF.pdf', configuration=config)
Seems you need to pass configuration=config
as argument.