python html如何轉成PDF?
問題描述
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為空字符串,沒有可以打開的文件
相關文章:
1. javascript - 微信小程序里怎么把頁面轉成圖片分享2. python3.x - Python中出現AttributeError: object has no attribute3. python把第x列數據寫入第x個文件4. python 多進程 或者 多線程下如何高效的同步數據?5. 微信端電子書翻頁效果6. mysql - 我用SQL語句 更新 行的時候,發現全部 中文都被清空了,請問怎么解決?7. mysql - SQL問個基礎例子,書上的,我怎么看都看不懂..誰幫我解釋一下第2個為什么和第1個一樣?8. 數據庫 - mysql boolean型無法插入true9. python - flask_Bootstrap的WTF的調用疑問10. mysql服務無法啟動1067錯誤,誰知道正確的解決方法?
