Python3转换html到pdf的不同解决方案
作者:网络整理 时间:2021-10-03 19:50:03
问题:python3 如何转换html到pdf
描述:
我的电脑是windows764位,python3.4
我想用python 转换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:
把可执行文件的路径加入到环境变量里
以上介绍了“python3 如何转换html到pdf”的问题解答,希望对有需要的网友有所帮助。
来源:http://www.codes51.com/itwd/1185819.html
标签:python,转换,html,pdf
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Keras使用ImageNet上预训练的模型方式
2021-03-01 10:08:51
![](https://img.aspxhome.com/file/2023/0/81840_0s.jpg)
python不到50行代码完成了多张excel合并的实现示例
2023-04-11 10:41:39
asp如何读取注册表的信息?
2009-11-19 21:18:00
利用Python求解阿基米德分牛问题
2023-11-10 09:36:48
![](https://img.aspxhome.com/file/2023/1/63531_0s.png)
MySQL数据库常见的出错代码及出错信息
2008-05-27 12:29:00
仅用500行Python代码实现一个英文解析器的教程
2022-06-15 02:15:25
![](https://img.aspxhome.com/file/2023/9/120959_0s.jpg)
python自动化测试中装饰器@ddt与@data源码深入解析
2021-10-08 16:07:14
![](https://img.aspxhome.com/file/2023/1/72951_0s.png)
在ASP.NET 2.0中操作数据之四十四:DataList和Repeater数据排序(三)
2023-07-02 04:45:57
![](https://img.aspxhome.com/file/2023/0/76340_0s.png)
python应用之如何使用Python发送通知到微信
2022-03-04 01:59:55
![](https://img.aspxhome.com/file/2023/6/102986_0s.png)
Oracle常用dump命令,记录一下备查。
2009-03-04 10:27:00
利用Python上传日志并监控告警的方法详解
2022-08-23 15:31:01
![](https://img.aspxhome.com/file/2023/7/69477_0s.png)
设计高效的faq页面
2011-06-10 13:13:00
python正则表达式对字符串的查找匹配
2022-02-21 12:39:50
python调用百度AI接口实现人流量统计
2022-09-10 12:46:27
![](https://img.aspxhome.com/file/2023/8/77688_0s.png)
Python脚本传参数argparse模块的使用
2023-02-28 23:07:21
![](https://img.aspxhome.com/file/2023/4/97724_0s.png)
Javascript 获取css属性
2009-05-31 16:49:00
python机器学习实现决策树
2021-04-21 07:44:34
![](https://img.aspxhome.com/file/2023/1/100911_0s.jpg)
golang中defer的基本使用教程
2023-07-03 01:19:02
![](https://img.aspxhome.com/file/2023/6/90486_0s.png)
详解Python中的from..import绝对导入语句
2022-08-10 10:01:33
基于Python制作flappybird游戏的详细步骤
2023-07-29 10:08:29
![](https://img.aspxhome.com/file/2023/2/60292_0s.jpg)