python html如何轉(zhuǎn)成PDF?
問題描述
import pdfkitpdfkit.from_url(’http://www.cocoachina.com/’, ’out.pdf’)
老報錯我已經(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行這句錯誤with open(self.wkhtmltopdf) as f:
應(yīng)該是self.wkhtmltopdf為空字符串,沒有可以打開的文件
相關(guān)文章:
1. mysql數(shù)據(jù)庫每次查詢是一條線程嗎?2. javascript - 前端開發(fā) 本地靜態(tài)文件頻繁修改,預(yù)覽時的緩存怎么解決?3. android - 優(yōu)酷的安卓及蘋果app還在使用flash技術(shù)嗎?4. java - public <T> T findOne(T record) 這是什么意思5. javascript - 數(shù)組原聲方法中的一段代碼6. JavaScript如何循序漸進(jìn),有效的學(xué)習(xí)?看不下去怎么辦?7. docker不顯示端口映射呢?8. css - 關(guān)于ul的布局9. python - linux怎么在每天的凌晨2點(diǎn)執(zhí)行一次這個log.py文件10. html5和Flash對抗是什么情況?
