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. python - pymysql建立連接出錯2. 默認(rèn)輸出類型為json,如何輸出html3. mysql 遠(yuǎn)程連接出錯10060,我已經(jīng)設(shè)置了任意主機(jī)了。。。4. python的正則怎么同時匹配兩個不同結(jié)果?5. 數(shù)組排序,并把排序后的值存入到新數(shù)組中6. php多任務(wù)倒計時求助7. MySQL的聯(lián)合查詢[union]有什么實際的用處8. PHP訂單派單系統(tǒng)9. html5 - css3scale和rotate同時使用轉(zhuǎn)換成matrix寫法該如何轉(zhuǎn)換?10. win10 python3.5 matplotlib使用報錯
