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

2021-03-10 20:41:36 +08:00
 rationa1cuzz
我在终端手动启动项目 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)
481 次点击
所在节点    问与答
1 条回复
rationa1cuzz
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] 句柄无效。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/760467

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX