Python pdfkit制作电子书

IOError: No wkhtmltopdf executable found: ""

从https://wkhtmltopdf.org/downloads.html下载wkhtmktopdf安装

import pdfkit

config = pdfkit.configuration(wkhtmltopdf=r"C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe") pdfkit.from_file(filename, fname, configuration = config) # fname = "xx.pdf"

File "/usr/local/lib/python2.7/dist-packages/pdfkit/pdfkit.py", line 119, in to_pdf raise IOError("wkhtmltopdf exited with non-zero code {0}. error:\n{1}".format(exit_code, stderr.decode("utf-8"))) IOError: wkhtmltopdf exited with non-zero code 1. error:

尝试了下,实际上上是有输出的,获取异常跳过,不过问题可能是wkhtmltopdf的版本和系统,相关的问题

import pdfkit
try:
config = pdfkit.configuration(wkhtmltopdf=r"C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe")
pdfkit.from_file(filename, fname, configuration = config) # fname = "xx.pdf"
except:
continue
 

猜你喜欢

转载自www.cnblogs.com/leilei-weapon/p/12448814.html