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