我正在尝试使用Python3中的pdfkit将html文件转换为PDF。我在macOS Mojave中使用了PyCharm,这是我在尝试运行代码时遇到的错误:
Traceback (most recent call last):
File "/Users/cesarvargas/miniconda3/envs/test/lib/python3.6/site-
packages/pdfkit/configuration.py", line 21, in __init__
with open(self.wkhtmltopdf) as f:
FileNotFoundError: [Errno 2] No such file or directory: b''
这是我正在使用的代码:
import pdfkit
if __name__ == "__main__":
with open("test.html") as f:
t = pdfkit.from_file(f, False)
答案 0 :(得分:0)
我已经解决了该错误,安装了WKHTMLtoPDF二进制文件:
https://wkhtmltopdf.org/downloads.html
更多信息在这里:
https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf