我试图在 google colab 中使用 imgkit 将 html 文件保存为图像。我很难让它工作。
!pip install imgkit
!pip install wkhtmltopdf
import imgkit
imgkit.from_file('file.html', 'out.jpg')
错误:
No wkhtmltoimage executable found: "command not found"
If this file exists please check that this process can read it.
Otherwise please install wkhtmltopdf - http://wkhtmltopdf.org
我读过我必须手动设置路径,但我无法弄清楚路径是什么。我还没有找到让它在Google Colab中工作的答案
谢谢!
编辑:感谢@user2314737 的回答,我成功了
%%bash
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.bionic_amd64.deb
拿到包后,我不得不把它复制到/usr/bin:
!cp wkhtmltox_0.12.6-1.bionic_amd64.deb /usr/bin
!sudo apt install /usr/bin/wkhtmltox_0.12.6-1.bionic_amd64.deb
然后只是:
import imgkit
imgkit.from_file('file.html', 'out.jpg')