3

I need to use pdfkit on Google Colab but I'm not able to make it works.

(I already use it on jupyter notebook on windows 10 withtout problem)

I tried installing like this:

! wget "https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-3/wkhtmltox-0.12.6-3.archlinux-x86_64.pkg.tar.xz" && \
tar vxfJ "wkhtmltox-0.12.6-3.archlinux-x86_64.pkg.tar.xz" && \
mv wkhtmltox/bin/wkhtmltopdf /usr/bin/wkhtmltopdf

It installed correctly.

I tried to make pdfkit point to the path "/content/usr/bin/wkhtmltopdf" but didn't work.

!pip install pdfkit
import pdfkit
path_wkhtmltopdf = "/content/usr/bin/wkhtmltopdf"
config = pdfkit.configuration(wkhtmltopdf=path_wkhtmltopdf)
pdfkit.from_url("test.html", "out.pdf", configuration=config)

The error returned:

Collecting pdfkit
  Downloading https://files.pythonhosted.org/packages/57/da/48fdd627794cde49f4ee7854d219f3a65714069b722b8d0e3599cd066185/pdfkit-0.6.1-py3-none-any.whl
Installing collected packages: pdfkit
Successfully installed pdfkit-0.6.1
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-9-b691bc3e9060> in <module>()
      3 path_wkhtmltopdf = "/content/usr/bin/wkhtmltopdf"
      4 config = pdfkit.configuration(wkhtmltopdf=path_wkhtmltopdf)
----> 5 pdfkit.from_url("yggtorrent1.html", "out.pdf", configuration=config)

1 frames
/usr/local/lib/python3.7/dist-packages/pdfkit/pdfkit.py in to_pdf(self, path)
    157 
    158         if exit_code != 0:
--> 159             raise IOError("wkhtmltopdf exited with non-zero code {0}. error:\n{1}".format(exit_code, stderr))
    160 
    161         # Since wkhtmltopdf sends its output to stderr we will capture it

OSError: wkhtmltopdf exited with non-zero code 1. error:
/content/usr/bin/wkhtmltopdf: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /content/usr/bin/wkhtmltopdf)
/content/usr/bin/wkhtmltopdf: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by /content/usr/bin/wkhtmltopdf)

0 Answers0