Selenium webdriver: unexpectedly exited. Status code was: 127

Question:
I cant get chrome webdriver to work, i have seen fix that has to do with the nix file but i can’t find the file when i enable the show hidden file
Repl link:
https://replit.com/@kingsleyebubeon/Python#hey.py

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys

chrome_options = Options()
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-dev-shm-usage")

driver = webdriver.Chrome(options=chrome_options)
driver.get("https:/google.com")

## Finding Elements

google_text = driver.find_element(By.CLASS_NAME, "MV3Tnb").text

print(google_text)

input_box = driver.find_element(By.NAME, "q")

## Typing and Clicking

input_box.send_keys("Hi")

input_box.send_keys(Keys.ENTER)

home_link = driver.find_element(By.ID, "logo")

home_link.click()

## Selectors

tag_search = driver.find_element(By.TAG_NAME, "a").text

print(tag_search)

link_text = driver.find_element(By.LINK_TEXT, "About").text

print(link_text)

error text

Traceback (most recent call last):
  File "/home/runner/Python/main.py", line 127, in <module>
    scraper = IG_Scraper("https://www.dailyfx.com/sentiment#view-more", "sentiment_data.db")
  File "/home/runner/Python/main.py", line 29, in __init__
    self.driver = self.setup_driver()
  File "/home/runner/Python/main.py", line 36, in setup_driver
    return webdriver.Chrome(options=options)
  File "/home/runner/Python/.pythonlibs/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
    super().__init__(
  File "/home/runner/Python/.pythonlibs/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 53, in __init__
    self.service.start()
  File "/home/runner/Python/.pythonlibs/lib/python3.10/site-packages/selenium/webdriver/common/service.py", line 102, in start
    self.assert_process_still_running()
  File "/home/runner/Python/.pythonlibs/lib/python3.10/site-packages/selenium/webdriver/common/service.py", line 115, in assert_process_still_running
    raise WebDriverException(f"Service {self._path} unexpectedly exited. Status code was: {return_code}")
selenium.common.exceptions.WebDriverException: Message: Service /home/runner/.cache/selenium/chromedriver/linux64/118.0.5993.70/chromedriver unexpectedly exited. Status code was: 127

Try after you add chromedriver to replit.nix: in Shell:

sed -i '/  ];/i\    pkgs.chromedriver/' replit.nix

You might then need to follow similar steps to How can I update chromedriver on replit for Selenium? - #4 by UMARismyname

I got this error
~/Python$ sed -i ‘/ ];/i\ pkgs.chromedriver/’ replit.nix
sed: can’t read replit.nix: No such file or directory

the issues i have is that replit.nix is not in my on replit workspace,

if you notice there is no replit.nix even tho i have enabled show hidden file

oh, in that case (should’ve said this earlier) use

nix-editor -ha pkgs.chromedriver

Thank you so much for the help, i got his error now

The chromedriver version (115.0.5790.98) detected in PATH at /nix/store/7ia44qd4nwn4ajcy1zq3zgv36lhg9k2m-chromedriver-115.0.5790.98/bin/chromedriver might not be compatible with the detected chrome version (118.0.5993.70); currently, chromedriver 118.0.5993.70 is recommended for chrome 118.*, so it is advised to delete the driver in PATH and retry
Traceback (most recent call last):
  File "/home/runner/Python/main.py", line 127, in <module>
    scraper = IG_Scraper("https://www.dailyfx.com/sentiment#view-more", "sentiment_data.db")
  File "/home/runner/Python/main.py", line 29, in __init__
    self.driver = self.setup_driver()
  File "/home/runner/Python/main.py", line 36, in setup_driver
    return webdriver.Chrome(options=options)
  File "/home/runner/Python/.pythonlibs/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
    super().__init__(
  File "/home/runner/Python/.pythonlibs/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 56, in __init__
    super().__init__(
  File "/home/runner/Python/.pythonlibs/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 205, in __init__
    self.start_session(capabilities)
  File "/home/runner/Python/.pythonlibs/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 289, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
  File "/home/runner/Python/.pythonlibs/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 344, in execute
    self.error_handler.check_response(response)
  File "/home/runner/Python/.pythonlibs/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, 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 /home/runner/.cache/selenium/chrome/linux64/118.0.5993.70/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Stacktrace:
#0 0x556f9ffae783 <unknown>
#1 0x556f9fcda917 <unknown>
#2 0x556f9fd05978 <unknown>
#3 0x556f9fd029c9 <unknown>
#4 0x556f9fd42a13 <unknown>
#5 0x556f9fd4215f <unknown>
#6 0x556f9fd39bd3 <unknown>
#7 0x556f9fd0da7b <unknown>
#8 0x556f9fd0e81e <unknown>
#9 0x556f9ff6fe98 <unknown>
#10 0x556f9ff73d67 <unknown>
#11 0x556f9ff7e32c <unknown>
#12 0x556f9ff74993 <unknown>
#13 0x556f9ff43827 <unknown>
#14 0x556f9ff988a8 <unknown>
#15 0x556f9ff98a36 <unknown>
#16 0x556f9ffa75f3 <unknown>
#17 0x7f5e757c6dd4 start_thread

but looks like you’d tried going for the Xvfb template I mentioned for Firefox. You’ll have to “use” the template I mentioned; the cover page main.py gives you some code that I was testing on that repl to see if there’s a better solution for Chrome.
Or, I think you can just replace

with webdriver.Chrome() as driver:

with

with xvfbwrapper.Xvfb(), webdriver.Firefox(options=options) as driver:
1 Like

Hello, I had the same issue with 127 error. After running the
nix-editor -ha pkgs.chromedriver

i also got the same (but now different from 127) type of error, as author had. And after updating selenium with:

poetry add selenium~4.10

  • it still throws the same error. I can’t understand how did the author handled it. May I ask for help here? Thank you in advance

My current error:

Traceback (most recent call last):
  File "/home/runner/Python/main.py", line 34, in <module>
    fetch_website(url)
  File "/home/runner/Python/main.py", line 15, in fetch_website
    driver = webdriver.Chrome(options=options)
  File "/home/runner/Python/.pythonlibs/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 49, in __init__
    super().__init__(
  File "/home/runner/Python/.pythonlibs/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 54, in __init__
    super().__init__(
  File "/home/runner/Python/.pythonlibs/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 206, in __init__
    self.start_session(capabilities)
  File "/home/runner/Python/.pythonlibs/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 291, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
  File "/home/runner/Python/.pythonlibs/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 346, in execute
    self.error_handler.check_response(response)
  File "/home/runner/Python/.pythonlibs/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 245, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
Stacktrace:
#0 0x5647f3a7b4e3 <unknown>
#1 0x5647f37aac76 <unknown>
#2 0x5647f37d1757 <unknown>
#3 0x5647f37d0029 <unknown>
#4 0x5647f380eccc <unknown>
#5 0x5647f380e47f <unknown>
#6 0x5647f3805de3 <unknown>
#7 0x5647f37db2dd <unknown>
#8 0x5647f37dc34e <unknown>
#9 0x5647f3a3b3e4 <unknown>
#10 0x5647f3a3f3d7 <unknown>
#11 0x5647f3a49b20 <unknown>
#12 0x5647f3a40023 <unknown>
#13 0x5647f3a0e1aa <unknown>
#14 0x5647f3a646b8 <unknown>
#15 0x5647f3a64847 <unknown>
#16 0x5647f3a74243 <unknown>
#17 0x7ff7d972be24 start_thread