1

I'm trying to setup a python application that uses Selenium and Chrome on PythonAnywhere. Everything is working in a development environment but I am running into issues when trying to deploy to PythonAnywhere. I'm getting the following traceback when attempting to run the code:

Traceback (most recent call last):
  File "/home/mattk/Door_Price/main.py", line 51, in <module>
    main()
  File "/home/mattk/Door_Price/main.py", line 13, in main
    catalog = Catalog(silent=True)
  File "./driver.py", line 29, in __init__
    self.driver = self._create_engine(path or config.PATH, silent)
  File "./driver.py", line 60, in _create_engine
    driver = 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__
    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 crashed.)
  (Driver info: chromedriver=85.0.4183.87 (cd6713ebf92fa1cacc0f1a598df280093af0c5d7-refs/branch-heads/4183@{#1689}),platform=Linux 5.4.0-1020-aws x86_64)

Not sure if PythonAnywhere needs some special configurations? Any help on this issue would be greatly appreciated.

Code causing error: @staticmethod def _create_engine(path, silent): """Generate Selenium Engine"""

    # TODO check if driver is present

    if silent:
        options = ChromeOptions()
        options.add_argument('--headless')
        driver = Chrome(
            executable_path=path,
            options=options
        )
    else:
        driver = Chrome(
            executable_path=path
        )

    return driver
4
  • Please add the part of the code that is returning the error. Commented Oct 2, 2020 at 21:32
  • @Jortega I've added the code Commented Oct 3, 2020 at 3:10
  • the error says the issue is coming from here File "/home/mattk/Door_Price/main.py", line 13, in main catalog = Catalog(silent=True) can you add this part of the code. Commented Oct 3, 2020 at 12:43
  • 1
    Write to [email protected] to have the required features enabled for your account. Commented Oct 3, 2020 at 16:30

3 Answers 3

1

Solved. PythonAnyWhere needed to enable some beta features on the account.

Sign up to request clarification or add additional context in comments.

Comments

1

You can't use PythonAnywhere and Selenium on Chrome by default, You need Firefox 17. Check this: https://help.pythonanywhere.com/pages/selenium/

1 Comment

You can't do it by default, but you can write to [email protected] to have the required features enabled for your account.
0

Your submission is somewhat confusing. I think to install on pythonanywhere you need add the "user" flag. Have you tried this?:

pip3 install [package] --user

In your case:

pip3 install selenium --user

But from this part of your traceback:

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=85.0.4183.87 (cd6713ebf92fa1cacc0f1a598df280093af0c5d7-refs/branch-heads/4183@{#1689}),platform=Linux 5.4.0-1020-aws x86_64)

it looks like selenium is already installed.

2 Comments

Selenium is installed. Does PythonAnywhere require any special configurations to run Selinum with Chrome?
you're better off asking this in the pythonanywhere forum here: pythonanywhere.com/forums

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.