pdfkit.from_url报错
import pdfkit # pdfkit.from_string pdfkit.from_url pdfkit.from_file -->html pdfkit.from_url('https://www.imooc.com','test1.pdf')
按照视频中的代码进行练习,运行后有报错。这个是什么原因。报错内容如下
��Ϣ: ���ṩ��ģʽ���ҵ��ļ��� Traceback (most recent call last): File "E:\Part1\Lib\site-packages\pdfkit\configuration.py", line 35, in __init__ with open(self.wkhtmltopdf) as f: ^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: b'' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "E:\pythonLearn\Part1\办公自动化\test3.py", line 7, in <module> pdfkit.from_url('https://www.imooc.com','test1.pdf') File "E:\Part1\Lib\site-packages\pdfkit\api.py", line 24, in from_url r = PDFKit(url, 'url', options=options, toc=toc, cover=cover, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\Part1\Lib\site-packages\pdfkit\pdfkit.py", line 45, in __init__ self.configuration = (Configuration() if configuration is None ^^^^^^^^^^^^^^^ File "E:\Part1\Lib\site-packages\pdfkit\configuration.py", line 38, in __init__ raise IOError('No wkhtmltopdf executable found: "%s"\n' OSError: No wkhtmltopdf executable found: "b''" If this file exists please check that this process can read it or you can pass path to it manually in method call, check README. Otherwise please install wkhtmltopdf - https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf 进程已结束,退出代码为 1
本地环境中已经安装了pdfkit
相关截图:
18
收起
正在回答 回答被采纳积分+1
1回答
好帮手慕小猿
2023-08-24 17:58:00
同学,你好!检查一下是否有安装 wkhtmltopdf 依赖包,并且要指定其 configuration 配置,详细步骤参考:https://class.imooc.com/lesson/2102#mid=58018
祝:学习愉快!
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星