Forums

Chrome driver in virtualenv for Selenium

Hello, I've been trying to install Selenium which could be utilized for my website, but there have been some complications.

These were the steps that i've taken for installation:

  1. Activate virtual environment (source senv/bin/activate)
  2. Download Selenium (pip install selenium)
  3. Download PyVirtualDisplay for a display server (pip install pyvirtualdisplay)
  4. Download and unpack latest chrome driver for linux (using wget's HTTP request)
  5. Add chrome driver's path to environmental variable $PATH (export PATH=$PATH:<path>)
  6. Testing: in Python shell, open a display server (Display(visible=0, size=(x, y)).start())
  7. Testing: in Python shell, select a webdriver for Selenium, specifying the absolute path (driver = webdriver.Chrome(executable_path="/home/MTonskins/<some_other_folder>/<my_app>/chromedriver")

Execution of step 7 prompted an error after waiting quite a while:

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed
  (Driver info: chromedriver=2.34.522913 (36222509aa6e819815938cbf2709b4849735537c),platform=Linux 4.4.0-101-generic x86_64

I'm not able to fully understand what could the problem be. Outside of virtual environment, Selenium, PyVirtualDisplay and Firefox driver are installed and are working by default, but there are some limitations, that's the reason why i want to run my script inside virtual environment.

So, what could the problem be? Am i doing something wrong? Also, i'm also wondering which web driver would be the fastest one that works in pythonanywhere servers? (Since, as i know, PhantomJS headless browser is not practical in web applications).

Thank you!

we don't support chrome i'm afraid. or phantomsj. more info here: http://help.pythonanywhere.com/pages/selenium

Thank you, Harry. So, will installation of latest Firefox web driver work in virtualenv? Or is it necessary to be done in actual environment?

HI there, am afraid not, only the system-installed firefox is supported. we know it's old. we're working on ways to upgrade it.

Is it possible to know approximate amount of time which will be required to upgrade Firefox? Since with current setup, i may not be able to make certain system. Also, is it possible to upgrade Firefox web driver individually? Or it has to be done for every user?

we have no timescale to announce regarding the upgrade of firefox. as far as we know, you can upgrade selenium, but not past version 2. it has to be done for every user yes.

Thank you for information!

Any update on when we might see a new version of Firefox installed? I have a project that I would love to use PythonAnywhere for, but FF17 is so out of date, it doesn't interact properly with the page I am looking to scrape .

Unfortunately we don't have a timeline as of now.

Do you have a timeline by now?

no- we don't have a timeline at the moment. Sorry!

This still seems to be an issue. Still no timeline I am guessing.

yes, sorry about that :(

This is still an issue , would be great to have a timeline for this or perhaps you could just be honest and say never

We have a new, experimental way of sandboxing users that should allow you to use a more recent version of Chrome. Let us know if you'd like us to enable it for your account.

@glenn Could you activate this feature on my account?

No problem. I have enabled it for your account. It will activate in new consoles and when you reload your web apps. Scheduled tasks will use it at their next start time and always on tasks will use it once they have been stopped and started.

Is it possible that you enable Chrome for my account too? I have looking to run my headless scripts but I get the message : WebDriverException('unknown error: no chrome binary at /usr/bin/google-chrome'

ok, we have enabled that for your account. that is not going to automatically give you a chrome binary though- it will just let a chrome binary run without errors. You can either download and build the chrome binary by youself, or we could switch you over to our newest system image. However, note that that may break your existing code, and you will have to rebuild any virtualenvs.

@glenn Thank you for activating this feature. I have a related question though. How can I stop the Chrome driver from logging in .org.chromium.Chromium.[random string] files in my /tmp/ folder to prevent the usage of space?

hmm the easiest may be to clear that /tmp folder say every day.

Well, I figured that but I thought there might be a more systemic solution.

Not that we know of, unfortunately.

Hi could you enable it on my account please as I need to use ChromeDriver for my 4th year project so i can use selenium thank you very much

Sure! That's done now. 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()

Yo can I get my account enabled for Chrome too please? Thanks.

It's done for you.

Yo can I get my account enabled for Chrome too please? Thanks.

Hello. I would like to get my system updated to python 3.8.2 and chrome enabled please if possible. Thank you

Sure! That's done.

I am not able to access chrome webdriver for scraping in flask file.Please enable chrome fro my account.

You already have the feature enabled for your account -- see my earlier post for the steps you need to take to use it.

Unable to get my program chromeTry.py run in headless mode as suggested above.

from selenium import webdriver chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--no-sandbox') chrome_options.add_argument('--disable-extensions') chrome_options.add_argument('--headless') chrome_options.add_argument('--disable-gpu') browser = webdriver.Chrome(chrome_options=chrome_options) browser.get("https://www.google.com") print( "Page title was '{}'".format(browser.title)) browser.quit()

Gives me the following error

Traceback (most recent call last): File "/home/arguptaHello/chromeTry.py", line 10, in <module> browser = webdriver.Chrome(chrome_options=chrome_options) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/webdriver.py", line 69, in init desired_capabilities=desired_capabilities) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 90, in init self.start_session(desired_capabilities, browser_profile) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 177, in start_session response = self.execute(Command.NEW_SESSION, capabilities) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute self.error_handler.check_response(response) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 192, 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) ============================================================= What should be done to get it working

As the rest of this thread says, we need to enable the new virtualisation system for your account. Any new consoles you start will be using it and your web apps will use after you reload. them.

Could you enable Chrome for my account as well? Would be greatly appreciated. Thanks

Please enable the new virtualisation system for my account.

@NMan1 -- sure, that's done now. @arguptaHello -- you already have the new system on your account.

@both: 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()

Hi, can I also have chrome enabled for my account? Thank you!

Sure! We've enabled that for you.

Hi, can I also have chrome enabled for my account? Thank you

We enabled it for you last week in response to another forum thread.

Hello, can I also have chrome enabled for my account? Thank you!

Sure, that's done. See my previous post for the next steps you need to take.

Hi giles, I'd like to use sand box that you said. Can i also have chrome enabled for my account? Thank you!

I had error like below

(myvirtualenv) 18:03 ~ $ python3.6 webdriver.py Traceback (most recent call last): File "webdriver.py", line 6, in <module> browser = webdriver.Chrome(options=chrome_options) File "/home/adonisgenie/.virtualenvs/myvirtualenv/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in init desired_capabilities=desired_capabilities) File "/home/adonisgenie/.virtualenvs/myvirtualenv/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in init self.start_session(capabilities, browser_profile) File "/home/adonisgenie/.virtualenvs/myvirtualenv/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "/home/adonisgenie/.virtualenvs/myvirtualenv/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/home/adonisgenie/.virtualenvs/myvirtualenv/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.)

ok, we have switched you over.

Hi support team i have the same issue as mentioned above , and it seems like my account needs to be added to the chrome driver allowed list , i am using the exact same settings

Sure, that's done. See my previous post for the next steps you need to take.

Hi, can I also have chrome enabled for my account? Thanks!

Sure, that's done. See my previous post for the next steps you need to take.

Hi, I need chrome for my Python bot, could you turn it on for me? thank you in advance

sure, we've turned that on for you. But keep in mind that as a free user you can only access our whitelist- you do not have unrestricted internet access.

Hi, can I have chrome on my account? I need it , thank you so much

sure, we've turned that on for you. But keep in mind that as a free user you can only access our whitelist- you do not have unrestricted internet access.

Hi, can I also have chrome enabled for my account please ? Thanks!

No problem. I have enabled it for your account. New consoles will use the new system and your web apps and always on tasks will use it once they've been reloaded/restarted and scheduled tasks will use it the next time they run.

@glenn, Hi! Could you also enable Chrome for my account, please? Thanks a lot

Sure, that's done. See my previous post for the next steps you need to take.

@glenn , Hi Could you please enable Chrome on my account there is a certain task I am not able to perform in Firefox. Thank You

To enable it for your account, we also need to do a system image update because your account is using an older system image. Switching to the new system may break some of your existing code that worked on older versions. You may need to recreate any virtualenvs that you're using and you will need to start new consoles and reload your web apps. Let us know if you'd still like to go ahead.

@glenn, Ya sure I'll do that please go-ahead, Thanks

No problem, that's done. Any new consoles you start will have the new system image, and your website and scheduled/always-on tasks will pick it up the next time they're restarted. Once you've checked that everything works OK with the system image update, then you can check out my previous post for the next steps you need to take in order to get started with Chrome.

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)

Please can you enable it for you

Sure, that's done. See my previous post for the next steps you need to take.

@conrad Hi , I can access Instagram via chrome but I can't do anything such as follow or unfollow people, what' s the problem? because of unrestricted internet access?

It's possible -- what does the page that is displayed when you try to do that say? You can get a screenshot from Selenium and save it to a file like this:

browser.get_screenshot_as_file(filename)

Thank you so much I found my problem, the problem was blocking my activity by Instagram as a bot.

Ah, that would explain it.

Can I also get chrome enabled for my selenium please?

Sure, that's done. See my previous post for the next steps you need to take.

Oh, so I upgraded selenium and copied your example code. But now I see this:

FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver': 'chromedriver'

can I see the full stacktrace?

`

Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 64, in start
    stdout=self.log_file, stderr=self.log_file)
  File "/usr/lib/python3.7/subprocess.py", line 756, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.7/subprocess.py", line 1499, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver': 'chromedriver'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/AzurLane/Bot/parser.py", line 8, in <module>
    browser = webdriver.Chrome(chrome_options=options)
  File "/usr/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 62, in __init__
    self.service.start()
  File "/usr/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 71, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home`

[edited by admin: formatting]

And sorry, I dont know how to enter code block...

Ah I see that you are still on an old system image- your image does not have chromedriver, so you will have to build the chrome binary yourself. Alternatively we could also switch you over to the latest system image- but that will require you to rebuild your virtualenvs and may break your code since python library versions would have changed.

I dont know much about rebuilding virtualenvs, but if all I should do is follow instructions in this (https://help.pythonanywhere.com/pages/RebuildingVirtualenvs) guide, then go ahead and switch me please.

No problem. I have migrated your account.

Hi, can I also have chrome enabled for my account? Thank you

Sure, I've switched that on for you.

Hi, can I also have chrome enabled for my account? Thank you

Ok. I have enabled it for your account.

can I have it enabled please? Been messing around all night trying to make a simple app work. Even tried spinning up an apache server on my raspberry pi. Would be very helpful to have the chromedriver. Thanks!

Okay, I have turned on the feature for you that would allow you to run chrome. If you also want it pre-installed for you, we can also switch you over to the newest system image. However, note that this may break your code and you will have to recreate your virtualenvs. Can you confirm if you want to do that?

sure, that shouldn't be a problem thanks!

Okay, we've switched you over! It will activate in new consoles and when you reload your web apps. Scheduled tasks will use it at their next start time and always on tasks will use it once they have been stopped and started.

so it seems chromedriver is installed to my $PATH but now getting an error from selenium

selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 83

Tried a few things from stack overflow like using webdriver-manager. Didn't work. Also found a pythonanywhere forum (https://www.pythonanywhere.com/forums/topic/21948/) discussing the same problem.

I tried upgrading selenium with/without virtualenv to no avail. My selenium version is also at 3.141.0 which according to pypi.org is the latest version. Tried using virtualenv python2/3.6/3.7 and the host's built-in python3.6. Also made sure to reload zhecht.pythonanywhere.com in the Web UI. Any help would be appreciated. Just wanted to say how awesome it is you respond to everyone here and how quickly too. Thanks!

Hi, can I have chrome enabled for my account? I don't seem to make it work :)

sure, I've enabled that for you. You will have to restart your consoles etc for it to take effect.

can you please install google-stable chrome so taht it can run with webdriver-manager I'm a paid user I'm in difficulty can you please do it

We already have a version of chromium installed that works with our virtualisation system and a chromedriver installed that works with it. Different versions of chromium and chrome may or may not work with our virtualisation system, so you should just use the one that is already there and that we know will work.

Can you shed more light on how to use your chromedriver, please? I get: Message: 'chromedriver' executable needs to be in PATH. Do you still need to enable my account?

@alvaropmartins Enabled it for you.

.

File "betting.py", line 19, in <module>
    betMaker = BetBot()
  File "/home/0310sawbuy0310/bet_bot.py", line 24, in __init__
    self.d = driver.chromedriver(PROXY, USER_AGENT)
  File "/home/0310sawbuy0310/driver.py", line 140, in chromedriver
    browser = webdriver.Chrome(desired_capabilities=caps, options=options)
  File "/home/0310sawbuy0310/.virtualenvs/my-virtualenv/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
    desired_capabilities=desired_capabilities)
  File "/home/0310sawbuy0310/.virtualenvs/my-virtualenv/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/home/0310sawbuy0310/.virtualenvs/my-virtualenv/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/home/0310sawbuy0310/.virtualenvs/my-virtualenv/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/home/0310sawbuy0310/.virtualenvs/my-virtualenv/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: 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-1106-aws x86_64)

Пишет такую ошибку. Помогите разобраться.

[edit by admin: formatting]

What happens if you run a script containing this simple Selenium code:

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()

...?

Firefox did it for me, thanks. I used https://www.pythonanywhere.com/forums/topic/26693/

Hello! Could you please enable the chromedriver in my account also? Thanks

No problem. I have enabled it for your account.

Hello!Could you please enable the chromedriver in my account also? Thanks

it's done for you

HI, when i try to load any web page other than google, am getting title as blank. code below chrome_options = webdriver.ChromeOptions() chrome_options.add_argument("--headless") chrome_options.add_argument("--disable-gpu") browser = webdriver.Chrome(options=chrome_options)

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

Free accounts can only connect out using http(s) to sites on our whitelist. If the site has a publicly documented API, send us a link to the API documentation and we'll consider it for the whitelist.

Hello! Could you please enable the chromedriver in my account also? Thank you so much! :)

No problem. I have enabled it for your account.

Hi, I'm not able to use the chrome driver for testing and getting error -selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally (unknown error: DevToolsActivePort file doesn't exist) - Is it because it's not enabled for my account ? Could you advise ? Thanks.

I don't think I've seen that specific error message before, but it could be caused the the feature not being active for your account, yes -- I've activated it now, and you can use it in any new consoles you start. See my previous post for the next steps you need to take.

Hey! Could you please enable the chrome driver in my account?

Sure, @FallenKnight, that's done for you.

Hello! Could you please enable the chromedriver in my account also?

@willthree123 It's done for you

Hey! I tried running my code again but I m getting an error am I doing something wrong?

  File "./instadm.py", line 54, in __init__
    self.driver = webdriver.Chrome(executable_path=CM().install(), options=chrome_options)
  File "./webdriver_manager/chrome.py", line 23, in __init__
    self.driver = ChromeDriver(name=name,
  File "./webdriver_manager/driver.py", line 54, in __init__
    self.browser_version = chrome_version(chrome_type)
  File "./webdriver_manager/utils.py", line 142, in chrome_version
    raise ValueError(f'Could not get version for Chrome with this command: {cmd}')
ValueError: Could not get version for Chrome with this command: google-chrome --version || google-chrome-stable --version
>>>

[edit by admin: formatting]

How does your code look like?

Its quite lengthy so I'll do it till where the errors are:

from instadm import InstaDM


with open(r'users.txt', 'r') as f:
    users = [line.strip() for line in f]

print(users)


insta = InstaDM(username='****', password='****', headless=True)<-------error in this line

for user in users:
    # Send message
    insta.sendMessage(user='****', message='Happy Birthday')

###############################################################################
The other file i.e. instadm
###############################################################################
from selenium import webdriver
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager as CM

from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.action_chains import ActionChains
from random import randint, uniform
from time import time, sleep
import logging
import sqlite3





DEFAULT_IMPLICIT_WAIT = 30

class InstaDM(object):

    def __init__(self, username, password, headless=True, instapy_workspace=None, profileDir=None):
        self.selectors = {
            "accept_cookies": "//button[text()='Accept']",
            "home_to_login_button": "//button[text()='Log In']",
            "username_field": "username",
            "password_field": "password",
            "button_login": "//button/*[text()='Log In']",
            "login_check": "//*[@aria-label='Home'] | //button[text()='Save Info'] | //button[text()='Not Now']",
            "search_user": "queryBox",
            "select_user": "//div[@aria-labelledby]/div/span//img[@data-testid='user-avatar']",
            "name": "((//div[@aria-labelledby]/div/span//img[@data-testid='user-avatar'])[1]//..//..//..//div[2]/div[2]/div)[1]",
            "next_button": "//button/*[text()='Next']",
            "textarea": "//textarea[@placeholder]",
            "send": "//button[text()='Send']"
        }

        # Selenium config
        options = webdriver.ChromeOptions()

        if profileDir:
            options.add_argument("user-data-dir=profiles/" + profileDir)

        if headless:
            options.add_argument("--headless")

        mobile_emulation = {
            "userAgent": 'Mozilla/5.0 (Linux; Android 4.0.3; HTC One X Build/IML74K) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19'
        }
        options.add_experimental_option("mobileEmulation", mobile_emulation)

        self.driver = webdriver.Chrome(executable_path=CM().install(), options=chrome_options)<----ERROR IN THIS LINE
        self.driver.set_window_position(0, 0)
        self.driver.set_window_size(414, 736)

[edit by admin: formatting]

Hi, can I also have chrome enabled for my account please ? Thanks!

@jrm -- sure, that's done. See my previous post for the next steps you need to take.

@FallenKnight -- it looks like the code in ./webdriver_manager/utils.py is assuming that you're using Chrome, while we have Chromium (the fully open-source version) installed. Is this file your code? If so, you can change it so that it checks for versions using chromium --version instead of google-chrome --version.

Thx! although I figured another way around I still ran into an issue the XPath that I am using does not match the XPath that the website has(instagram.com) with this version of chromium on linux. To change it I will have to use headless=False to inspect the elements but when I am doing so it says :(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 5.4.0-1029-aws x86_64) Any way around that?

You still need to use headless mode -- there's no display on our servers for Chrome to connect to. Try using the driver.get_screenshot_as_file(filename) function to take screenshots of the page in cases where it looks like it's displaying a page different to the one that you expect.

Hey again! I am sorry if I am troubling you too much but I ran the code last night fixed all the issues and turned off my pc but this morning I try running it again and it gives me the same error as before even when I try running:

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)

try:
    browser.get("https://www.google.com")

    print("Page title was '{}'".format(browser.title))
finally:
    browser.quit()

sorry again for the trouble.

Where do you run that? What is "the same error"?

I ran it in my from the same file as my project (bot.py)

The error:

File "/home/FallenKnight/bot.py", line 7, in <module>
browser = webdriver.Chrome(options=chrome_options)
File "./selenium/webdriver/chrome/webdriver.py", line 76, in __init__
RemoteWebDriver.__init__(
File "./selenium/webdriver/remote/webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "./selenium/webdriver/remote/webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "./selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "./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: 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 crash
 ed.)
(Driver info: chromedriver=2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac),platform=Linux 
5.4.0-1029-aws x86_64)

How have you installed Selenium? The paths in that traceback look strange, as if you've embedded some version of the package directly into your code.

Oh right! although I did use my version of selenium I deleted it and installed selenium for the web driver from the bash console but I am getting the same error:

  File "/home/FallenKnight/bot.py", line 7, in <module>
  browser = webdriver.Chrome()
  File "/usr/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 65, in __init__
  RemoteWebDriver.__init__(
  File "/usr/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 90, in __init__
  Traceback (most recent call last):
   File "/home/FallenKnight/bot.py", line 7, in <module>
   browser = webdriver.Chrome()
   File "/usr/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 65, in __init__
   RemoteWebDriver.__init__(

   File "/usr/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 65, in __init__
   File "/usr/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 90, in __init__
   self.start_session(desired_capabilities, browser_profile)
   File "/usr/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 177, in start_session
   response = self.execute(Command.NEW_SESSION, capabilities)
   File "/usr/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
   self.error_handler.check_response(response)
   File "/usr/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, 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 crash
 ed.)
(Driver info: chromedriver=2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac),platform=Linux 
5.4.0-1029-aws x86_64)

I am running the same code as the one above i.e. https://www.pythonanywhere.com/forums/topic/12225/#id_post_90288

Idk what can be done but maybe deleting the stuff for enabling the driver and "installing" them again will work? But that's just a hypothesis.

Try running

pip3.8 install --user --upgrade selenium

...and see if that helps.

Still the same error:(

What do you see if you run which chromium and which chromedriver in your console?

I don't get anything when I run 'which chromium' and I get'/usr/local/bin/chromedriver' when I run 'which chromedriver'

Sorry. I think @giles meant which chromium-browser

oh, I get /usr/bin/chromium-browser when I do that

Ok. Both of those look correct. It may then be the installation that you spoke of earlier. You can try deleting the .local directory on your home directory and then re-installing the modules that you need to use.

Umm that did not work I got another error BUT I made another account and asked for activation the username is loafy I tried to run the same code there and it worked! I probably messed something up in this account

It does sound like something must have been broken in your account, yes! Glad to hear you have it working in the new one. If you particularly prefer the username that you're using in this thread, but you don't have anything that you want to keep in this account, we could delete it entirely and then you could sign back up as FallenKnight again -- if you want to do that, send us an email at support@pythonanywhere.com to request the account deletion.

Hi, can I also have chrome enabled for my account please ? Thanks!

No problem, I have enabled it for your account.

I am getting an error again so just asking is it possible to create multiple accounts under the same email? because i really need this by today thx! Edit: Oh nvm I reinstalled the packages and its normal again sorry for the trouble!

Hi, can I also have chrome enabled for my account please?

No problem, I have enabled it for your account.

sorry asked to have it enabled but realized you guys have that feature now

It should work for everyone.

Hi, can you please enable Chrome for my account too?

It is already enabled for your account.

Same here. How do I go about this? (myvirtualenv) 18:18 ~ $ pip install chromium-chromedriver
Looking in links: /usr/share/pip-wheels ERROR: Could not find a version that satisfies the requirement chromium-chromedriver (from versions: none) ERROR: No matching distribution found for chromium-chromedriver

chromium-chromedriver is not a pip package. You also do not need to install it. It is already installed on the newer system image than your current one. You can update your system image from your Account page.

Thank you for quick response. How do I update system image?

@tweetologist Take a look at https://help.pythonanywhere.com/pages/ChangingSystemImage

Hello! Can you please enable Chrome to my account?

It is already enabled for all accounts.

Hello! Can you please enable Chrome to my account to?

It is already enabled for all accounts.

Hi! I would like to run a python code which works well in local using webdriver.Firefox(service=FirefoxService(GeckoDriverManager().install())). However, I cannot make it work in pythonanywhere. Someone make it work? thanks

You need to use Chrome on PythonAnywhere as Firefox does not work correctly.

Hi, I am getting this error with just these codes:

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)

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

finally:
    browser.quit()

and here are the error messages:

Traceback (most recent call last):
  File "/home/WisetechJimmy/autorun python/test.py", line 6, in <module>
    browser = webdriver.Chrome(options=chrome_options)
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 70, in __init__
    super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 92, in __init__
    RemoteWebDriver.__init__(
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 275, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 365, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 430, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 247, 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 is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Stacktrace:
#0 0x557900b2de89 <unknown>

What am I doing wrong? Thanks.

See https://help.pythonanywhere.com/pages/selenium/

Hey can i activate chrome for my account

Thank you

All accounts have Chrome activated by default nowadays. What problems are you having using it? If you try the minimal Selenium example on this help page, does it work?

this is my code, with the example code you provided, it work. but when i try with my own website, and configurarations, it doesn't work.

from selenium import webdriver import random import time import pandas as pd from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import Select, WebDriverWait

df = pd.read_excel('visa.xlsx')

chrome_options = webdriver.ChromeOptions() chrome_options.add_argument("--no-sandbox") chrome_options.add_argument("--headless") chrome_options.add_argument("--disable-gpu") chrome_options.add_argument("--disable-dev-shm-usage") chrome_options.add_argument('--window-size=1920,1080') chrome_options.add_argument("--ignore-certificate-errors") chrome_options.add_argument("--allow-running-insecure-content")

web = webdriver.Chrome(options=chrome_options)

try: web.get('https://##########') # Replace with the actual URL for i in df.index: # Loop through each entry in the DataFrame while True:
try: entry = df.loc[i] wait = WebDriverWait(web, 10)

            # Select Visa Type
            VisaType = wait.until(EC.element_to_be_clickable((By.NAME, 'visa_type')))
            Select(VisaType).select_by_value(str(entry['Visa Type']))
            time.sleep(random.uniform(1, 3))

        except Exception as e:
            print(f"An error occurred: {e}")
            break  # Exit the loop if an error occurs

        time.sleep(120)

finally: web.quit()

this is the error i get

<pre><code> An error occurred: Message: Stacktrace:

0 0x55b7f5ba4e89 <unknown>

</code></pre>

What line is that error raised on?

its not showing the line number, that is the whole error I get from the bash terminal of pythonanywhere. I used chatGPT, and it says, there might be that the website you are trying to access is not permitted by pythonanywhere. Is it possible if you whitelist me the website I am trying to access ?

Ok i solved the previouse problem.

Now i added a proxy to my code by using the following line of argument.

chrome_options.add_argument('--proxy-server=proxyhostname:Proxyport')

This worked properly in my local computer runned it using pycharm. but when i runed it using pythonanywhere it was giving me error of timeoutexception. means the page was loading but coudn't conect to the website i was trying to connect. But if i was commenting the proxy argument line (means i was not using proxy while runing in pythonanywhere), then my code could run properly.

I am using a paid proxy. which my provider can give me both authenticated or whitelisted proxies.

Can you please help me with that ? meabye there is another way of configuring proxies using pythonanywhere.

Thank you

Have you started a fresh console since you upgraded to a paid plan?

Yes I am using upgraded version since the begining.

I really need to solve this, because i stuck in this part in my project

Thank you

Check with your proxy provider. Some places block access from AWS where PythonAnywhere is hosted.