Im trying to save an html file as an image using imgkit in google colab. Im having trouble making it work.
!pip install imgkit
!pip install wkhtmltopdf
import imgkit
imgkit.from_file('file.html', 'out.jpg')
Error:
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
I´ve read I have to set the path manually, but i can´t figure out what the path is. I haven't found answers about making it work in Google Colab
Thks!
Edit: I made it work thanks to @user2314737 answer
%%bash
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.bionic_amd64.deb
After geting the package I had to copy it to /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
And then just:
import imgkit
imgkit.from_file('file.html', 'out.jpg')
You need to install the executable. Check your operating system with
!cat /etc/os-release
# Out:
# NAME="Ubuntu"
# VERSION="18.04.5 LTS (Bionic Beaver)"
# ...
and check processor architecture with !uname -m
(I get Ubuntu x86_64)
Then install the executable with
!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
Here's the list of all downloads: https://wkhtmltopdf.org/downloads.html