python html如何轉(zhuǎn)成PDF?
問(wèn)題描述
import pdfkitpdfkit.from_url(’http://www.cocoachina.com/’, ’out.pdf’)
老報(bào)錯(cuò)我已經(jīng)安裝了wkhtmltopdf :還請(qǐng)大神幫忙解決!
還有如何將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
問(wèn)題解答
回答1:首先是你21行這句錯(cuò)誤with open(self.wkhtmltopdf) as f:
應(yīng)該是self.wkhtmltopdf為空字符串,沒(méi)有可以打開(kāi)的文件
相關(guān)文章:
1. android - Genymotion 微信閃退 not find plugin.location_google.GoogleProxyUI2. mac里的docker如何命令行開(kāi)啟呢?3. android webview返回自動(dòng)刷新4. docker綁定了nginx端口 外部訪問(wèn)不到5. angular.js - 關(guān)于ng-model和ng-bind的疑問(wèn)6. html5 - 微信瀏覽器視頻播放失敗7. html - 特殊樣式按鈕 點(diǎn)擊按下去要有凹下和彈起的效果8. javascript - 單個(gè)控件多個(gè)字段搜索9. objective-c - iOS開(kāi)發(fā)使用什么對(duì)html進(jìn)行代碼高亮10. javascript - npm安裝報(bào)錯(cuò) 系統(tǒng)w7 求大神解答
