Python3轉(zhuǎn)換html到pdf的不同解決方案
問題:python3 如何轉(zhuǎn)換html到pdf
描述:
我的電腦是windows764位,python3.4
我想用python 轉(zhuǎn)換html到pdf.
我嘗試了html2pdf,貌似它只支持Python2
我又嘗試了wkhtmltox-0.12.2.2_msvc2013-win64和pdfkit,并用下面的例子測試。
import pdfkit
pdfkit.from_url('http://google.com', 'out.pdf')
報錯信息
Traceback (most recent call last):
File "E:\Python34\lib\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 "<pyshell#2>", line 1, in <module>
pdfkit.from_url('http://google.com', 'out.pdf')
File "E:\Python34\lib\site-packages\pdfkit\api.py", line 22, in from_url
c
File "E:\Python34\lib\site-packages\pdfkit\pdfkit.py", line 38, in __init__
self.configuration = (Configuration() if configuration is None
File "E:\Python34\lib\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:
直接使用里邊的wkhtmltopdf即可
wkhtmltopdf http://google.com a.pdf
解決方案2:
把可執(zhí)行文件的路徑加入到環(huán)境變量里
以上介紹了“python3 如何轉(zhuǎn)換html到pdf”的問題解答,希望對有需要的網(wǎng)友有所幫助。
總結(jié)
以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學習或者工作具有一定的參考學習價值,謝謝大家對腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請查看下面相關(guān)鏈接
相關(guān)文章
python中?OpenCV和Pillow處理圖像操作及時間對比
這篇文章主要介紹了python中OpenCV和Pillow處理圖像操作及時間對比,文章圍繞主題展開詳細的內(nèi)容介紹,具有一定的參考價值,需要的小伙伴可以參考一下2022-09-09
Python docx庫刪除復(fù)制paragraph及行高設(shè)置圖片插入示例
這篇文章主要為大家介紹了Python docx庫刪除復(fù)制paragraph及行高設(shè)置圖片插入操作實現(xiàn)示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-07-07
Python開發(fā)中爬蟲使用代理proxy抓取網(wǎng)頁的方法示例
這篇文章主要介紹了Python開發(fā)中爬蟲使用代理proxy抓取網(wǎng)頁的方法,結(jié)合具體實例形式分析了urllib模塊代理與requests模塊代理兩種實現(xiàn)技巧,需要的朋友可以參考下2017-09-09
10 行 Python 代碼教你自動發(fā)送短信(不想回復(fù)工作郵件妙招)
這篇文章主要介紹了10 行 Python 代碼教你自動發(fā)送短信(不想回復(fù)工作郵件妙招),目前在國內(nèi)通過手機短信保障信息安全是比較常見的,具體實例代碼大家跟隨小編一起通過本文學習吧2018-10-10

