Forums

Activate headless Chrome on my account

Hi there,

I've been having issues with virtual displays when using Selenium and saw that you activated headless Chrome on another account on this post:

https://eu.pythonanywhere.com/forums/topic/16/#id_post_46

Could you do the same for my account?

Thanks!

No problem. I have updated your account.

Thanks!

About activation of Chrome headless in my account

could you please activate chrome in my account ?

Sure, we have tweaked that for you. Any new consoles that you start / webapps that you reload / tasks that restart etc will be in the new name space. You can check this by doing a ps in it. This will not error (old consoles will say you don't have the permissions to do so).

Please note that because you are still on an old system image, you may have to build the chrome binary yourself unless you also switch that over- but that will require you to rebuild your virtualenvs and may break your code since library versions would have changed.

Good evening, could you activate chrome browser in my account aswell? Thank you!

OK, vaska1234, it's done for you.

Hello, Could you please do the same for my account as well? FirefoxDriver is not working on my code.

Just for clarity -- with our new system, we strongly advise you to use Chrome in headless mode, not Firefox -- Chrome tends to be more reliable. With that said, the new virtualisation system is now active for your account. Any new consoles you start will use the new system, scheduled tasks will pick it up the next time they run, and websites/always-on tasks the next time they're restarted.

You'll need to upgrade Selenium to the most recent version for the version of Python that you're using, eg. "pip install --upgrade selenium" if you're using a virtualenv, or "pip3.7 install --user --upgrade selenium" to upgrade it for Python 3.7 if you're not).

Once that's done, this sample code might be useful:

            chrome_options = webdriver.ChromeOptions()
            chrome_options.add_argument("--headless")
            chrome_options.add_argument("--disable-gpu")
            browser = webdriver.Chrome(options=chrome_options)

            try:
                browser.get("https://www.google.com")
                return "Page title was '{}'".format(browser.title)

            finally:
                browser.quit()

Hello there! Could you also activate chrome browser for my account? Not sure how to (and if it is even possible) to build Chrome binaries from the console.

Thanks giles!! Your sample code works on my account.
But when I replace "https://www.google.com" with "https://www.amazon.com" or "https://www.microsoft.com/en-us", browser.title becomes null.
Would you happen to know the difference between them and how to solve this issue?

You have a free account. You can only access sites on the whitelist: https://www.pythonanywhere.com/whitelist/

@glenn Oh, I see. Thank you for your information.

Hi giles, may I enable my account as well? Also, is it necessary to have chromedriver uploaded? If so, for what OS? Thank you

No problem. I have updated your account. There is a chromedriver already installed and available.

Okay, this is what I'm getting:

>>> import selenium
>>> from selenium import webdriver
>>> chrome_options = webdriver.ChromeOptions()
>>> chrome_options.add_argument("--headless")
>>> chrome_options.add_argument("--disable-gpu")
>>> browser = webdriver.Chrome(options=chrome_options)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/samcha/.local/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __i
nit__
    desired_capabilities=desired_capabilities)
  File "/home/samcha/.local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __
init__
    self.start_session(capabilities, browser_profile)
  File "/home/samcha/.local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in st
art_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/home/samcha/.local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in ex
ecute
    self.error_handler.check_response(response)
  File "/home/samcha/.local/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in
 check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is a
ssuming that Chrome has crashed.)
  (Driver info: chromedriver=2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac),platform=Linux 4.4.0-1095-aw
s x86_64)

Is there something I can do on my end to get past this point? Thank you very much.

I have enabled the new virtualisation system for your account. So, in a new console, the headless option should now work.

Excellent, thank you very much!

About activation of Chrome headless in my account could you please activate chrome in my account ? I am using chrome 80 stable version. I am facing below error: selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally (unknown error: DevToolsActivePort file doesn't exist)

You'll need to use the version of Chrome that we have pre-installed rather than one that you installed yourself, unless you also want to keep Chromedriver up-to-date. But your account has Chrome 78 installed, which is pretty recent.

In order to make it work, you'll need to upgrade Selenium for your account -- for example, if you're using Python 3.7, run this in Bash:

pip3.7 install --user --upgrade selenium

...and then you can run Selenium with Chrome using code like this:

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
browser = webdriver.Chrome(options=chrome_options)

try:
    browser.get("https://www.google.com")
    print("Page title was '{}'".format(browser.title))

finally:
    browser.quit()

Just stumbled across this thread, could I have chrome activated for my account? Thanks.

Sure! That's done now. See my last post on this thread for the next steps.

It is still saying 'chromedriver' executable needs to be in PATH, as in this thread

I am not seeing chromedriver in /usr/local/bin. Anything else that needs to be upgraded in order for this to work is fine with me.

Please note that because you are still on an old system image, you may have to build the chrome binary yourself unless you also switch that over- but that will require you to rebuild your virtualenvs and may break your code since library versions would have changed. Let us know if you want us to switch you over to the latest system image (it will also add python 3.7 and 3.8 to your account)

Are there instructions anywhere on how to build the chrome binary myself? Do I need to download a specific version?

You can't build Chrome yourself (it's Google proprietary), but you can build Chromium, the open-source base of Chrome. Instructions should be on the Internet. You may also be able to download either Chrome or Chromium binaries for Ubuntu 64bit and then install it into your home directory.

I have tried installing it myself but I am getting the same error as samcha above. So I guess I need to go with the new system image then?

It looks that way. Would you like us to update your system image?

yes please

No problem. That's done.

Just come across this topic, would love to try headless chrome too. Can I try?

@adminviczo, it's done for you.

Thank you very much!

Good evening, could you activate chrome browser in my account too? Thank you!

I have responded to your post in the other thread.

Hi, can you please activate chrome in my account? Thanks!

Sure, I have done that for you. You will have to restart your consoles/reload your webapps etc for the change to take place.

>>> import selenium >>> from selenium import webdriver >>> chrome_options = webdriver.ChromeOptions() >>> chrome_options.add_argument("--headless") >>> chrome_options.add_argument("--disable-gpu") >>> browser = webdriver.Chrome(options=chrome_options) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/venky6888/.virtualenvs/mydjanproj/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__ desired_capabilities=desired_capabilities) File "/home/venky6888/.virtualenvs/mydjanproj/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__ self.start_session(capabilities, browser_profile) File "/home/venky6888/.virtualenvs/mydjanproj/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "/home/venky6888/.virtualenvs/mydjanproj/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/home/venky6888/.virtualenvs/mydjanproj/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.) (Driver info: chromedriver=2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac),platform=Linux 4.4.0-1100-aws x86_64) >>> from webdriver_manager.chrome import ChromeDriverManager >>> driver = webdriver.Chrome(ChromeDriverManager().install(),options = options) /bin/sh: 1: google-chrome: not found Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/venky6888/.virtualenvs/mydjanproj/lib/python3.6/site-packages/webdriver_manager/chrome.py", line 24, in install driver_path = self.download_driver(self.driver) File "/home/venky6888/.virtualenvs/mydjanproj/lib/python3.6/site-packages/webdriver_manager/manager.py", line 32, in download_driver driver_version, is_latest = self.__get_version_to_download(driver) File "/home/venky6888/.virtualenvs/mydjanproj/lib/python3.6/site-packages/webdriver_manager/manager.py", line 23, in __get_version_to_download return self.__get_latest_driver_version(driver), True File "/home/venky6888/.virtualenvs/mydjanproj/lib/python3.6/site-packages/webdriver_manager/manager.py", line 17, in __get_latest_driver_version return driver.get_latest_release_version() File "/home/venky6888/.virtualenvs/mydjanproj/lib/python3.6/site-packages/webdriver_manager/driver.py", line 54, in get_latest_release_version self._latest_release_url + '_' + chrome_version()) File "/home/venky6888/.virtualenvs/mydjanproj/lib/python3.6/site-packages/webdriver_manager/utils.py", line 98, in chrome_version .format(cmd) ValueError: Could not get version for Chrome with this command: google-chrome --version Getting this error can you activate chrome on my account? Thanks!

@venky6888, it's done for you

Hi, can you please activate chrome in my account? Thanks!

No problem, that's done now -- see my earlier post for the next steps you need to take to use it.

Hi, I have the same issue, can you please activate chrome in my account? Thanks a lot!

Error running WSGI application selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.) (Driver info: chromedriver=2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac),platform=Linux 4.4.0-1100-aws x86_64)

driver = webdriver.Chrome(options=chrome_options) File "/home/nipunhedaoo/.local/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in init desired_capabilities=desired_capabilities) File "/home/nipunhedaoo/.local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in initself.start_session(capabilities, browser_profile) File "/home/nipunhedaoo/.local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "/home/nipunhedaoo/.local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response File "/home/nipunhedaoo/.local/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace)

I'm getting these errors. I've changed the code as you've given in previous comments, can you help? Thanks

@YuliaArKa - no problem that's done

@nipunhedaoo - It looks like you were leaving processes lying around so you got to a point where you had so many processes that you could not start any more. I have killed those processes for you, so you should have more success now. Also, make sure that you are trying to run the code in a console that was created after the account change.

Hi, I have the same issue, can you please activate chrome in my account? Thanks a lot!

No problem. I have updated your account.

Hi, I have the same issue, can you please activate chrome in my account? Thanks a lot!

No problem, that's done now -- see my earlier post for the next steps you need to take to use it.

Hi , I want to use Selenium with Headless Chrome on your server with my account . Can you please enable the access to use it ?

No problem, that's done now -- see my earlier post for the next steps you need to take to use it.

could you please activate chrome browser in my account?

No problem, that's done now -- see my earlier post for the next steps you need to take to use it.

hello, please enable for me also

No problem, that's done now -- see my earlier post for the next steps you need to take to use it.

to access kite.trade which is already supported in your list, should i need to purchase subscription plan?

If a site is in the whitelist, then you don't need a paid account to access it. However, the whitelist only covers APIs, so for the site you mention, api.kite.trade is on the whitelist, but kite.trade is not.

Hi, Can you activate chrome in my account?

No problem, that's done now -- see my earlier post for the next steps you need to take to use it.

Please activate chrome in my account.

Hi, can you please activate chrome in my account?

No problem, that's done now -- see my earlier post for the next steps you need to take to use it.

Hello, Can you please activate chrome in my account as well. :)

Sure, I've done that for you.

hey, can u activate chrome for my account? its need for my bot :(

Hi, can you please activate chrome in my account? Thanks!

@IIIAYPMA228 -- the new virtualization system is already active on your account -- perhaps you contacted one of my colleagues over some other channel?

@colony66694 -- no problem, that's done now -- see my earlier post for the next steps you need to take to use it.

Hello, Giles et. al. Is it possible for me to to have Chrome activated for my account?

If it already is, when I try to run browser = webdriver.Chrome(options=chrome_options) I am getting a TypeError: __init__() got an unexpected keyword argument 'options'

Any assistance on this? Thanks!

sure, I just turned that on for you. For that particular error though, it seems like there may be a selenium version mismatch.

Message: unknown error: Chrome failed to start: exited abnormally (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.) (Driver info: chromedriver=2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac),platform=Linux 4.4.0-1100-aws x86_64)

Hey is it a error due to not activated account ?? can you please do that

@Itzkartik I activated it for you.

Hi, could you activate Chrome in my account?

sure, we've switched that on for you

Hello, could you activate Chrome in my account? Thanks!

No problem, that's done now -- see my earlier post for the next steps you need to take to use it.

Hello, could you please enable Chrome for me?

I have error: (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.) (Driver info: chromedriver=2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac),platform=Linux 4.4.0-1100-aws x86_64)

sure, I've turned that on for you.

Hi Conrad,

Please could you activate the chrome driver on my account? Im getting the following error: init() got an unexpected keyword argument 'options'

Thanks,

No problem, that's done now -- see my earlier post for the next steps you need to take to use it.

Hello. Would you please enable the chrome browser for my account? I have the crashing problem as well.

Ok. I have enabled it for your account.

Please activate headless chrome on my account

I have responded to your other post.

Hi there! Could you also activate chrome browser for my account? thx!

No problem, that's done now -- see my earlier post for the next steps you need to take to use it.

Hi! Could you also activate chrome browser for my account?

Hi, I request Chrome browser to be activated for my account as well please. I'm trying to scrape a thing from http://www.salt-partners.com/ but I keep getting following error:

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac),platform=Linux 4.4.0- 1106-aws x86_64

I did it for you, but you have to know, that with the free account your options will be very limited.

When downloading a file through headless Chrome, where does it end up in Python Anywhere? I used the following code, but the file does not seem to end up there even though my code runs without error.

prefs = {"download.default_directory" : '/files/home/user/temp'}
chrome_options.add_experimental_option('prefs', prefs)

Is '/files/home/user/temp' the exact path that you're using? That wouldn't work, it would need to be a full Linux path, like '/home/smircovich/something'

Below is the exact code I am using, but the file downloaded in the script is not ending up in the temp directory I created:

prefs = {"download.default_directory" : '/home/smircovich/temp'}
chrome_options.add_experimental_option('prefs', prefs)

What if you try with trailing /

?

Hi, could I get Chrome browser enabled for my Selenium please?

Have responded to the new post you made here

Hello, can you please enable the headless Chrome for my selenium too, please?

No problem, that's done now -- see my earlier post for the next steps you need to take to use it.

Hi, can you please enable the headless Chrome for my selenium too, please? Thank you in advance!

No problem, that's done now

Can you please install chrome google stable so that webdriver_manager can do his magic

The chrome that is available in your account is the most recent that we currently have.

Hi, can you please enable the headless Chrome for my selenium too, please? Thank you in advance!

No problem, that's done now -- see my earlier post for the next steps you need to take to use it.

Hi, can you please enable the headless Chrome for my selenium too, please? Thank you in advance!

@newfiepicks No problem. It's done for you.

Hello , could you please enable the headless Chrome for my selenium ? And also I would like to know what happened with cookies?

Hello there could you please enable headless Chrome for my selenium? I would like to get some data from google. Thank you!

@sinfsr, flaskgmscaper -- no problem, that's done now -- see my earlier post for the next steps you need to take to use it.

Also, @sinfsr -- not sure what you mean about cookies...?

I Getting this unfortunately "The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed."

It seems it's because I have a free account.. I have one question that can I run a .py in another web hosting (like heroku) and import that here??

Both should running nun-stop

It seems I need to a direction on my account like (home/usn/bla.py imported from url or st.)

@giles

headless chrome does not appear to be working on mine either. Could I get it activated for my account? Thank you!

@smith7929 no problem, that's activated for your account and will work in new consoles. See my earlier post for the next steps you need to take to use it.

@sinfsr -- no, I don't think the problem is because you have a free account -- Chrome should work fine. What happens if you run the minimal Chrome script in my previous post?

Regarding running a Python script in one hosting platform and importing it from another -- do you mean that you'd like to run the code there, and then get the results in some other code running here? You'd need to set things up on the other platform so that it ran as a website, or something like that, and then access that site from your code here.