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')
報(bào)錯(cuò)信息
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)容對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請查看下面相關(guān)鏈接
相關(guān)文章
Python實(shí)現(xiàn)的redis分布式鎖功能示例
這篇文章主要介紹了Python實(shí)現(xiàn)的redis分布式鎖功能,結(jié)合實(shí)例形式分析了Python操作redis分布式鎖與解鎖功能相關(guān)操作技巧,需要的朋友可以參考下2018-05-05
利用Django-environ如何區(qū)分不同環(huán)境
這篇文章主要給大家介紹了關(guān)于利用Django-environ如何區(qū)分不同環(huán)境的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用django具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2018-08-08
pytorch多GPU并行運(yùn)算的實(shí)現(xiàn)
這篇文章主要介紹了pytorch多GPU并行運(yùn)算的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-09-09
Python的Flask框架中實(shí)現(xiàn)簡單的登錄功能的教程
這篇文章主要介紹了Python的Flask框架中實(shí)現(xiàn)簡單的登錄功能的教程,登錄是各個(gè)web框架中的基礎(chǔ)功能,需要的朋友可以參考下2015-04-04
從零學(xué)python系列之?dāng)?shù)據(jù)處理編程實(shí)例(二)
這篇文章主要介紹了python數(shù)據(jù)處理編程實(shí)例,需要的朋友可以參考下2014-05-05

