1

I'm trying to run my crawler using selenium, webdriver and xvfb on pythonanywhere server (if it can help). I also tried to use pyvirtualdisplay instead of xvfb to create a browser window for webdriver. But I keep receiving error "Message: Service /usr/bin/chromium-browser unexpectedly exited. Status code was: 127"

Traceback:

File "/home/Sayn0toWar/.virtualenvs/parser/lib/python3.7/site-packages/django/core/handlers/exception.py" in inner 34. response = get_response(request)

File "/home/Sayn0toWar/.virtualenvs/parser/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response 115. response = self.process_exception_by_middleware(e, request)

File "/home/Sayn0toWar/.virtualenvs/parser/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response 113. response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/Sayn0toWar/parser_test/parser_test/main/views.py" in index 13. main(int(iterations))

File "/home/Sayn0toWar/parser_test/parser_test/main/parser_script.py" in main 111. b = Bot(iterations)

File "/home/Sayn0toWar/parser_test/parser_test/main/parser_script.py" in init 24. self.driver = webdriver.Chrome(executable_path='/usr/bin/chromium-browser', chrome_options=options)

File "/home/Sayn0toWar/.virtualenvs/parser/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py" in init 73. self.service.start()

File "/home/Sayn0toWar/.virtualenvs/parser/lib/python3.7/site-packages/selenium/webdriver/common/service.py" in start 98. self.assert_process_still_running()

File "/home/Sayn0toWar/.virtualenvs/parser/lib/python3.7/site-packages/selenium/webdriver/common/service.py" in assert_process_still_running 111. % (self.path, return_code)

Exception Type: WebDriverException at / Exception Value: Message: Service /usr/bin/chromium-browser unexpectedly exited. Status code was: 127

My code:

from bs4 import BeautifulSoup
from selenium import webdriver
from webdrivermanager import ChromeDriverManager
from xvfbwrapper import Xvfb
from pyvirtualdisplay import Display
from time import sleep


class Bot:
    def __init__(self, iterations):        
        display = Display(visible=0, size=(800, 600))
        display.start()
        cdm = ChromeDriverManager()
        chromedriver_path = cdm.download_and_install()
        options = webdriver.ChromeOptions()        
        options.add_argument('--headless')
        options.add_argument('--no-sandbox')        
        self.driver = webdriver.Chrome(executable_path='/usr/bin/chromium-browser', chrome_options=options)
        self.navigate(iterations)
        self.close()
        display.stop()

I am sorry for my code, i'm not good at python yet and just trying to make script work for several days, it seems to me there were visited all resources that contain any information about this error. Chrome and chromedriver both have the same version 78, all necessary dependences are installed. And I have no idea what can i do else. May somebody help, please?

Community
  • 1
  • 1
  • Welcome to SO. Please take the time to read [ask] and [mcve]. It will help you craft solid questions that will hopefully get useful answers. Not sure if this SO answer helps: https://stackoverflow.com/questions/49323099/webdriverexception-message-service-chromedriver-unexpectedly-exited-status-co Good luck! – orde Nov 19 '19 at 02:29
  • PythonAnywhere dev here: Chrome doesn't work on PythonAnywhere right now, though that is likely to change over the coming week or so. If you send an email to support@pythonanywhere.com asking to be notified when it does work, we'll let you know. – Giles Thomas Nov 20 '19 at 12:14

0 Answers0