pdfkit.from_url运行报错

pdfkit.from_url运行报错

运行:

pdfkit

pdfkit.from_url

提示错误:

C:\Users\Administrator\PycharmProjects\untitled\venv\Scripts\python.exe C:/Users/Administrator/PycharmProjects/word/test4.py

��Ϣ: ���ṩ��ģʽ�޷��ҵ��ļ���

Traceback (most recent call last):

  File "C:\Users\Administrator\PycharmProjects\untitled\venv\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 "C:/Users/Administrator/PycharmProjects/word/test4.py", line 5, in <module>

    pdfkit.from_url('https://www.imooc.com','test1.pdf')

  File "C:\Users\Administrator\PycharmProjects\untitled\venv\lib\site-packages\pdfkit\api.py", line 24, in from_url

    r = PDFKit(url, 'url', options=options, toc=toc, cover=cover,

  File "C:\Users\Administrator\PycharmProjects\untitled\venv\lib\site-packages\pdfkit\pdfkit.py", line 45, in __init__

    self.configuration = (Configuration() if configuration is None

  File "C:\Users\Administrator\PycharmProjects\untitled\venv\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


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

1回答
好帮手慕雪 2021-12-28 10:30:23

同学,你好!由于版本问题,请同学:

1)下载wkhtmltopdf安装包,并且安装到电脑上
下载地址:https://wkhtmltopdf.org/downloads.html


2)在pycharm中安装wkhtmltopdf库:

pip install wkhtmltopdf


3)在代码中指定configuration参数


pdfkit
__name__ == :
    path_wk = config = pdfkit.configuration(= path_wk)
    pdfkit.from_url(,,=config)


https://img1.sycdn.imooc.com//climg/61ca764409d3e16a10610184.jpg

祝:学习愉快


问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师