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. 測試自動化html元素選擇器元素ID或DataAttribute [關(guān)閉]2. html5和Flash對抗是什么情況?3. 運行python程序時出現(xiàn)“應(yīng)用程序發(fā)生異常”的內(nèi)存錯誤?4. javascript - QQ第三方登錄的問題5. node.js - mongodb查找子對象的名稱為某個值的對象的方法6. 利用IPMI遠(yuǎn)程安裝centos報錯!7. 在mac下出現(xiàn)了兩個docker環(huán)境8. spring-mvc - spring-session-redis HttpSessionListener失效9. java - Spring boot 讀取 放在 jar 包外的,log4j 配置文件,系統(tǒng)有創(chuàng)建日志文件,不寫入日志信息。10. 正在使用electron和node.js做桌面應(yīng)用,需要實時監(jiān)聽是否有網(wǎng)絡(luò)連接,node或者electron是否可以做到

網(wǎng)公網(wǎng)安備