Python3轉(zhuǎn)換html到pdf的不同解決方案
問(wèn)題:python3 如何轉(zhuǎn)換html到pdf
描述:
我的電腦是windows764位,python3.4
我想用python 轉(zhuǎn)換html到pdf.
我嘗試了html2pdf,貌似它只支持Python2
我又嘗試了wkhtmltox-0.12.2.2_msvc2013-win64和pdfkit,并用下面的例子測(cè)試。
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
請(qǐng)大神們告訴我,該怎么做呢?
解決方案1:
直接使用里邊的wkhtmltopdf即可
wkhtmltopdf http://google.com a.pdf
解決方案2:
把可執(zhí)行文件的路徑加入到環(huán)境變量里
以上介紹了“python3 如何轉(zhuǎn)換html到pdf”的問(wèn)題解答,希望對(duì)有需要的網(wǎng)友有所幫助。
總結(jié)
以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對(duì)腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請(qǐng)查看下面相關(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)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用django具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2018-08-08pytorch多GPU并行運(yùn)算的實(shí)現(xiàn)
這篇文章主要介紹了pytorch多GPU并行運(yùn)算的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-09-09Python的Flask框架中實(shí)現(xiàn)簡(jiǎn)單的登錄功能的教程
這篇文章主要介紹了Python的Flask框架中實(shí)現(xiàn)簡(jiǎn)單的登錄功能的教程,登錄是各個(gè)web框架中的基礎(chǔ)功能,需要的朋友可以參考下2015-04-04Python使用線程來(lái)接收串口數(shù)據(jù)的示例
今天小編就為大家分享一篇Python使用線程來(lái)接收串口數(shù)據(jù)的示例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-07-07從零學(xué)python系列之?dāng)?shù)據(jù)處理編程實(shí)例(二)
這篇文章主要介紹了python數(shù)據(jù)處理編程實(shí)例,需要的朋友可以參考下2014-05-05