成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_99国内精品久久久久久久

您的位置:首頁技術(shù)文章
文章詳情頁

python html如何轉(zhuǎn)成PDF?

瀏覽:153日期:2022-08-07 13:35:50

問題描述

import pdfkitpdfkit.from_url(’http://www.cocoachina.com/’, ’out.pdf’)

老報(bào)錯(cuò)我已經(jīng)安裝了wkhtmltopdf :還請大神幫忙解決!

還有如何將wkhtmltopdf的執(zhí)行路徑添加到系統(tǒng)環(huán)境$PATH變量中?

Traceback (most recent call last): File '/Library/Frameworks/Python.framework/Versions/3.6/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’’During handling of the above exception, another exception occurred:Traceback (most recent call last): File '/Users/peibobo/PycharmProjects/bottle/pdf_test.py', line 3, in <module> pdfkit.from_url(’http://www.cocoachina.com/’, ’out.pdf’) File '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pdfkit/api.py', line 24, in from_url configuration=configuration, cover_first=cover_first) File '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pdfkit/pdfkit.py', line 42, in __init__ self.configuration = (Configuration() if configuration is None File '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pdfkit/configuration.py', line 27, in __init__ ’https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf’ % self.wkhtmltopdf)OSError: No wkhtmltopdf executable found: 'b’’'If this file exists please check that this process can read it. Otherwise please install wkhtmltopdf - https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf

問題解答

回答1:

首先是你21行這句錯(cuò)誤with open(self.wkhtmltopdf) as f:

應(yīng)該是self.wkhtmltopdf為空字符串,沒有可以打開的文件

標(biāo)簽: Python 編程
相關(guān)文章: