V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
rationa1cuzz
V2EX  ›  问与答

iis 上跑就报 OSError: [WinError 6] 句柄无效。跪求大佬看看

  •  
  •   rationa1cuzz · 2021-03-10 20:41:36 +08:00 · 475 次点击
    这是一个创建于 1177 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我在终端手动启动项目 python manage.py runserver 没问题
    代码如下
    import imgkit
    path_wkimg = r'C:\Program Files\wkhtmltopdf\bin\wkhtmltoimage.exe' # 工具路径
    cfg = imgkit.config(wkhtmltoimage=path_wkimg)
    options = {"encoding": "UTF-8"} # 这个具体要看你那个 html 页面到底是以什么编码格式保存的
    if not prefix:
    prefix = str(uuid.uuid4())
    img_file_path = r'd:\xx.png'
    imgkit.from_string(html_str, img_file_path, config=cfg, options=options)
    rationa1cuzz
        1
    rationa1cuzz  
    OP
       2021-03-10 20:42:59 +08:00
    错误日志:
    File ".\Plugin\imgkit.py", line 25, in generate_img_html
    cfg = imgkit.config(wkhtmltoimage=path_wkimg)
    File "c:\yjpt\api\venv\lib\site-packages\imgkit\api.py", line 101, in config
    return Config(**kwargs)
    File "c:\yjpt\api\venv\lib\site-packages\imgkit\config.py", line 24, in __init__
    stdout=subprocess.PIPE).communicate()[0].strip()
    File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 665, in __init__
    errread, errwrite) = self._get_handles(stdin, stdout, stderr)
    File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 919, in _get_handles
    errwrite = _winapi.GetStdHandle(_winapi.STD_ERROR_HANDLE)
    OSError: [WinError 6] 句柄无效。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2452 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 00:04 · PVG 08:04 · LAX 17:04 · JFK 20:04
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.