【问题标题】:pdfkit [WinError 740] The requested operation requires elevation python3pdfkit [WinError 740] 请求的操作需要提升 python3
【发布时间】:2020-01-08 08:13:23
【问题描述】:

我想在给定的 url 上将 html 页面最好地转换为 pdf。我试过 pdfkit 但它给了我 [WinError 740] 请求的操作需要提升。

import pdfkit
path_wkthmltopdf = "D:\\w.exe"
config = pdfkit.configuration(wkhtmltopdf = path_wkthmltopdf )
pdfkit.from_url("http://www.google.com", 'd:\\out.pdf', configuration=config)

输出错误:

n [42]: import pdfkit
path_wkthmltopdf = "D:\\w.exe"
config = pdfkit.configuration(wkhtmltopdf = path_wkthmltopdf )

pdfkit.from_url("http://www.google.com", 'd:\\out.pdf', configuration=config)
Traceback (most recent call last):

  File "<ipython-input-42-58323936ac63>", line 5, in <module>
    pdfkit.from_url("http://www.google.com", 'd:\\out.pdf', configuration=config)

  File "C:\Users\31081\AppData\Local\conda\conda\envs\ml\lib\site-packages\pdfkit\api.py", line 26, in from_url
    return r.to_pdf(output_path)

  File "C:\Users\31081\AppData\Local\conda\conda\envs\ml\lib\site-packages\pdfkit\pdfkit.py", line 129, in to_pdf
    stderr=subprocess.PIPE)

  File "C:\Users\31081\AppData\Local\conda\conda\envs\ml\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 143, in __init__
    super(SubprocessPopen, self).__init__(*args, **kwargs)

  File "C:\Users\31081\AppData\Local\conda\conda\envs\ml\lib\subprocess.py", line 729, in __init__
    restore_signals, start_new_session)

  File "C:\Users\31081\AppData\Local\conda\conda\envs\ml\lib\subprocess.py", line 1017, in _execute_child
    startupinfo)

OSError: [WinError 740] The requested operation requires elevation

【问题讨论】:

  • 嘿@Abhishek,你有没有解决过这个问题。我也遇到了

标签: python-3.x pdfkit


【解决方案1】:

我也遇到过这个问题,我通过运行.exe解决了这个问题,运行后它会创建一个新的目录,进入这个目录然后bin dir你会在那里找到一个exe文件 C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe 因此,将“D:\w.exe”替换为代码中的上述路径即可

【讨论】:

  • 你太棒了...非常感谢。
【解决方案2】:

当我没有完成 wkpdftohtml 库的完整安装时,我遇到了这个问题。打开包装后,无需提升即可运行。

【讨论】:

    猜你喜欢
    • 2020-09-26
    • 2021-09-05
    • 2011-10-30
    • 1970-01-01
    • 2014-10-25
    • 2013-02-08
    • 2021-11-17
    • 1970-01-01
    • 2011-05-10
    相关资源
    最近更新 更多