Open TytoCapensis opened 2 years ago
Hello, thank you for opening an issue.
Edit : I don't know why I didn't thought of it right away, but the more practical way would be to change the value of the browser's _executable
attribute :
>>> from html2image import Html2Image
>>> hti = Html2Image()
>>> hti.browser
<html2image.browsers.chrome.ChromeHeadless object at 0x000001896B3A9490>
>>> hti.browser._executable
'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'
>>> hti.browser._executable = YOUR_NEW_EXECUTABLE_PATH
Other method that should still work:
A way to temporarily solve your problem would be to set the HTML2IMAGE_TOGGLE_ENV_VAR_LOOKUP
environment variable to any value (example : true
), and set an environment variable with any of the following names :
HTML2IMAGE_CHROME_BIN
HTML2IMAGE_CHROME_EXE
CHROME_BIN
CHROME_EXE
to the path of your Chromium executable. Html2image iterates over these environment variable names in the same order as they are listed above. If CHROME_BIN
is already set on your system but you wish not to keep its content and not use it, you can set HTML2IMAGE_CHROME_BIN
for example.Although this feature has yet to be documented and tested, it should do the trick, as the path provided using this method are not subject to any tests.
Regarding a fix, an argument could indeed be added the Html2Image class' __init__()
, for instance.
I am using a Red Hat Enterprise Linux machine (version 8.3) with Python 3.6.8 and the current version of html2image.
On this distribution, several choices are presented when we want to install Chromium on it :
I went for the last option since it looked the most convenient for our use case.
Instead of the usual Chromium package which install the full browser with its standard executable, this package installs only a Chromium "headless shell", located in
/usr/lib64/chromium-browser/headless_shell
The issue I have is that, unlike the classic Chromium versions, this executable fails the executable check in html2image:
This is because
/usr/lib64/chromium-browser/headless_shell --version
apparently does not give the Chromium version as expected. It should be noted that, if I bypass the check by commenting it, everything works fine except that (I am able to make "screenshots" of pages normally).I am unsure how this issue could be correctly fixed, maybe a special flag or condition could be implemented.