imgkit
imgkit copied to clipboard
No wkhtmltoimage executable found error on google colab
Describe the bug During conversion of string to image (or any other usage of the package), I am faced with the following error:
SError:
No wkhtmltoimage executable found: "command not found"
I have installed wkhtmltopdf
but issue persists. As far as I understand, there is no wkhtmltoimage
package to install.
To Reproduce
- Go to google colab
- Run:
import imgkit
imgkit.from_string('Hello!', 'out.jpg')
- See error
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-7-cb1f5c445c5d> in <module>()
----> 1 imgkit.from_string('Hello!', 'out.jpg')
2 frames
/usr/local/lib/python3.7/dist-packages/imgkit/config.py in get_wkhtmltoimage(self)
55 raise_from(OSError(wkhtmltoimage_error), io_error)
56 else:
---> 57 raise OSError(wkhtmltoimage_error)
58
59 return self.wkhtmltoimage
OSError:
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
Additional info
I have tried manually setting the path to wkhtmltopdf
using
path_wkthmltopdf = r'/home/cdsw/.local/lib/python3.6/site-packages/wkhtmltopdf/'
config = imgkit.config(wkhtmltoimage=path_wkthmltopdf)
imgkit.from_string('Hello!', 'out.jpg', config=config)
but with no luck receiving the similar errortrace
IsADirectoryError Traceback (most recent call last)
/home/cdsw/.local/lib/python3.6/site-packages/imgkit/config.py in get_wkhtmltoimage(self)
51 try:
---> 52 with open(self.wkhtmltoimage):
53 pass
IsADirectoryError: [Errno 21] Is a directory: '/home/cdsw/.local/lib/python3.6/site-packages/wkhtmltopdf/'
The above exception was the direct cause of the following exception:
OSError Traceback (most recent call last)
<ipython-input-59-85ebba294e78> in <module>()
13 <p style='font-size: 0.8em; width: 600px; height: 400px;'>
14 {content}
---> 15 </p>""", os.getcwd(), options=options, config=config)
/home/cdsw/.local/lib/python3.6/site-packages/imgkit/api.py in from_string(string, output_path, options, toc, cover, css, config, cover_first)
104 css=css,
105 config=config,
--> 106 cover_first=cover_first,
107 )
108 return rtn.to_img(output_path)
/home/cdsw/.local/lib/python3.6/site-packages/imgkit/imgkit.py in __init__(self, url_or_file, source_type, options, config, **kwargs)
34 self.source = Source(url_or_file, source_type)
35 self.config = Config() if not config else config
---> 36 self.wkhtmltoimage = self.config.get_wkhtmltoimage()
37
38 self.options = {}
/home/cdsw/.local/lib/python3.6/site-packages/imgkit/config.py in get_wkhtmltoimage(self)
53 pass
54 except IOError as io_error:
---> 55 raise_from(OSError(wkhtmltoimage_error), io_error)
56 else:
57 raise OSError(wkhtmltoimage_error)
/home/cdsw/.local/lib/python3.6/site-packages/six.py in raise_from(value, from_value)
OSError:
No wkhtmltoimage executable found: "/home/cdsw/.local/lib/python3.6/site-packages/wkhtmltopdf/"
If this file exists please check that this process can read it.
Otherwise please install wkhtmltopdf - http://wkhtmltopdf.org
- OS: Google Colab and Cloudera Workbench (same issue)
- IMGkit Version [1.2.2]
-
wkhtmltopdf
[0.2]
I may sound dumb but did you installed wkhtmltopdf/image
to google collab and is it in $PATH. The error message semes clear: No wkhtmltoimage executable found: "command not found"
. Does is really exists?