我试图使用google中的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')发布于 2022-01-28 12:31:33
您需要安装可执行文件。检查您的操作系统
!cat /etc/os-release
# Out:
# NAME="Ubuntu"
# VERSION="18.04.5 LTS (Bionic Beaver)"
# ...并使用!uname -m检查处理器架构。
(我得到了Ubuntu x86_64)
然后将可执行文件安装到
!wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.bionic_amd64.deb
!cp wkhtmltox_0.12.6-1.bionic_amd64.deb /usr/bin
!sudo apt install /usr/bin/wkhtmltox_0.12.6-1.bionic_amd64.deb以下是所有下载的列表:https://wkhtmltopdf.org/downloads.html
https://stackoverflow.com/questions/70893465
复制相似问题