首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PDFKit FileNotFoundError Python

PDFKit FileNotFoundError Python
EN

Stack Overflow用户
提问于 2018-11-16 14:29:06
回答 2查看 4.3K关注 0票数 1

我试图使用Python3中的pdfkit将html文件转换为PDF。我在使用PyCharm和macOS Mojave,这是我试图运行代码时遇到的错误:

代码语言:javascript
复制
   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''

这是我正在使用的代码:

代码语言:javascript
复制
import pdfkit

if __name__ == "__main__":
    with open("test.html") as f:
        t = pdfkit.from_file(f, False)
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-11-19 19:05:56

我已经解决了错误,安装了WKHTMLtoPDF二进制文件:

https://wkhtmltopdf.org/downloads.html

更多信息在这里:

https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf

票数 3
EN

Stack Overflow用户

发布于 2022-03-03 05:38:40

我是在窗户机器上执行的。这就是我如何解决问题的方法:从以下链接安装wkhtmltopdfhttps://wkhtmltopdf.org/downloads.html

C:\Program Files\wkhtmltopdf\bin添加到环境变量路径

重新启动终端。现在它会起作用的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53339794

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档