我试图使用Python3中的pdfkit将html文件转换为PDF。我在使用PyCharm和macOS Mojave,这是我试图运行代码时遇到的错误:
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)发布于 2018-11-19 19:05:56
我已经解决了错误,安装了WKHTMLtoPDF二进制文件:
https://wkhtmltopdf.org/downloads.html
更多信息在这里:
https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf
发布于 2022-03-03 05:38:40
我是在窗户机器上执行的。这就是我如何解决问题的方法:从以下链接安装wkhtmltopdf:https://wkhtmltopdf.org/downloads.html
将C:\Program Files\wkhtmltopdf\bin添加到环境变量路径。
重新启动终端。现在它会起作用的。
https://stackoverflow.com/questions/53339794
复制相似问题