国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

python html如何轉成PDF?

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

問題描述

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

老報錯我已經安裝了wkhtmltopdf :還請大神幫忙解決!

還有如何將wkhtmltopdf的執行路徑添加到系統環境$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行這句錯誤with open(self.wkhtmltopdf) as f:

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

標簽: Python 編程
相關文章:
主站蜘蛛池模板: 米易县| 桑植县| 庄浪县| 西华县| 邵东县| 德州市| 舞阳县| 宣恩县| 富宁县| 汶川县| 武山县| 仁化县| 电白县| 张北县| 洛浦县| 汶川县| 义乌市| 甘洛县| 益阳市| 泸定县| 巴林左旗| 台中市| 偏关县| 营山县| 衢州市| 汨罗市| 上林县| 郴州市| 吉安县| 会宁县| 洞口县| 福清市| 长兴县| 平邑县| 五原县| 余江县| 湖南省| 出国| 汝州市| 山阳县| 湘潭市|