IOError: No wkhtmltopdf executable found

#IOError: No wkhtmltopdf executable found: “”

python使用pdfkit中,如果使用pdfkit.from_url 或者pdfkit.from_string等,就会出现上述错误。而且如果你使用pip安装了 wkhtmltopdf,还是会出现这个问题:
If this file exists please check that this process can read it. Otherwise please install wkhtmltopdf - https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf

因此需要去安装windows版本的wkhtmltopdf
此处进入下载网址
安装完成之后需要在代码中添加以下内容:

path_wk = r'C:\Python27\wkhtmltopdf\bin\wkhtmltopdf.exe' #安装位置
config = pdfkit.configuration(wkhtmltopdf = path_wk)
pdfkit.from_url(url, r'D:\are you coding\pdf\taobao.pdf', configuration=config)

如此即可实现了

comments powered by Disqus