2

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')
user2314737
  • 27,088
  • 20
  • 102
  • 114
Ignacio Basti
  • 97
  • 2
  • 10

1 Answers1

3

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

Edmar Miyake
  • 12,047
  • 3
  • 37
  • 38
user2314737
  • 27,088
  • 20
  • 102
  • 114
  • Do i need to set a specific path? im getting this error now: OSError: wkhtmltoimage exited with non-zero code 1. error: /usr/local/bin/wkhtmltoimage: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /usr/local/bin/wkhtmltoimage) /usr/local/bin/wkhtmltoimage: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by /usr/local/bin/wkhtmltoimage) – Ignacio Basti Jan 28 '22 at 12:43
  • 1
    @IgnacioBasti corrected the answer with the right version --> Ubuntu 18 Bionic amd64 – user2314737 Jan 28 '22 at 13:37