lzjun567 / python_scripts

一些python相关的演示代码
Apache License 2.0
716 stars 526 forks source link

win7转pdf时候提示wkhtmltopdf reported an error #8

Open de8ug opened 7 years ago

de8ug commented 7 years ago
  File "crawler.py", line 163, in <module>
    crawler.run()
  File "crawler.py", line 97, in run
    pdfkit.from_file(htmls, self.name + ".pdf", options=options)
  File "C:\Anaconda3\envs\py3-dj\lib\site-packages\pdfkit\api.py", line 49, in from_file
    return r.to_pdf(output_path)
  File "C:\Anaconda3\envs\py3-dj\lib\site-packages\pdfkit\pdfkit.py", line 156, in to_pdf
    raise IOError('wkhtmltopdf reported an error:\n' + stderr)
OSError: wkhtmltopdf reported an error:
Loading pages (1/6)
Warning: Failed to load http://www.liaoxuefeng.comhttp//service.t.sina.com.cn/widget/qmd/1658384301/078cedea/2.png (ignore)
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done
Exit with code 1 due to network error: ProtocolUnknownError
zixinzhao commented 2 years ago

所以要怎么解决???解决了吗??

zixinzhao commented 2 years ago

Traceback (most recent call last): File "D:\install\pthon-3.10\lib\code.py", line 90, in runcode exec(code, self.locals) File "", line 1, in File "D:\install\pycharm\PyCharm 2021.3.3\plugins\python\helpers\pydev_pydev_bundle\pydev_umd.py", line 198, in runfile pydev_imports.execfile(filename, global_vars, local_vars) # execute the script File "D:\install\pycharm\PyCharm 2021.3.3\plugins\python\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "D:/pythonpro/娱乐/中国文库网/将单个网页转成pdf.py", line 78, in pdfkit.from_file(html_path, pdf_path,configuration=config) File "D:\install\pthon-3.10\lib\site-packages\pdfkit\api.py", line 51, in from_file return r.to_pdf(output_path) File "D:\install\pthon-3.10\lib\site-packages\pdfkit\pdfkit.py", line 201, in to_pdf self.handle_error(exit_code, stderr) File "D:\install\pthon-3.10\lib\site-packages\pdfkit\pdfkit.py", line 155, in handle_error raise IOError('wkhtmltopdf reported an error:\n' + stderr) OSError: wkhtmltopdf reported an error: Exit with code 1 due to network error: ProtocolUnknownError