-
-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not Getting Image #39
Comments
Hello, thanks for opening an issue. This problem is not directly related to this package but the fact that there is not any error message is indeed troublesome. I checked myself using heroku, and it seems that adding a buildpack is not enough to "install" it, you will have to deploy your app for the buildpack to be applied. I'm not really a heroku user, so it may not be the right way to do it, but you can check if chrome is correctly installed by "connecting" via bash to you app using the Heroky CLI:
Then you can try running chrome:
If you get a "file not found", it may be because the buildpack has not been applied. To apply it, you need to deploy your app (you can find different ways to do so via your heroku dashboard > your app > deploy tab). After deploying the app, the Chrome executable was here I was able to take a screenshot. I hope this can help you. In all cases do not close the issue, I'll take a look at why there isn't any error message. |
yes ik, I deployed correctly and path is also there, but same issue image not saving. |
Now I changed heroku stack to container (root docker) used custom flag and path from html2image import Html2Image
hti = Html2Image(custom_flags=['--no-sandbox'])
hti.browser_executable = "/usr/bin/google-chrome"
html = """<h1> An interesting title </h1> This page will be red"""
css = "body {background: red;}"
file = hti.screenshot(html_str=html, css_str=css, save_as='red_page.png') It worked , 👍👍 btw how can we get a good quality image? |
Hey, |
Hi @vgalin I am using docker and the browser is not installed on the system.
The browser is installed as a service from docker-compose Service in docker-compose
When executed, the browser works correctly and displays the content of the page But when I run my script I get an error What I need write in hti.browser_executable ? Or maybe I'm using the wrong image for the browser? |
Hi again @vgalin :) Decided just add this line to my app dockerfile Error about "Could not find a Chrome" disappeared but now I get other errors
My Dockerfile
|
Hello @Leventi Concerning the new errors, these are outputted directly by Chromium. They are harmless most of the time and it can be difficult or impossible to get rid of them, so if your screenshot is generated properly, you could ignore them. |
Thx @vgalin |
Similar issue with deploying to Render. As it was said from render: Chrome is not installed by default on Render Native Runtimes
Start Command should have the following: After this I did include hti.browser_executable to my python code and still was getting FileNotFoundError
|
@ser-zhm Both are undocumented features, but you can force the browser path using two methods. The first one is creating an instance of >>> from html2image import Html2Image
>>> hti = Html2Image()
>>> hti.browser._executable # check the current executable filepath
'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'
>>> hti.browser._executable = ... # set a different executable filepath The second one relies on environment variables but is quite unreliable for the moment. To try it:
If done properly, Html2Image should display some kind of message, like so: >>> from html2image import Html2Image
>>> Html2Image()
Found a potential chrome executable in the "your filepath" environment variable:
"your filepath" (The message leaves a lot to be desired.) |
Thanks for reply. |
As-is, the browser executable cannot be changed afterwards using Concerning To summarize : This behavior is probably too confusing to be left as-is, doing everything from |
Python 3.9.5
html2image 2.0.1
I'm using Chrome heroku buildpack
Its Not saving Image + No error logs
@vgalin Thanks
The text was updated successfully, but these errors were encountered: