Python Selenium Error - Sandbox cannot access executable - Stack Overflow

时间: 2025-01-06 admin 业界

I wanted to make a automatic login bot with Python and Selenium, but I keep getting an Error.

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
browser = webdriver.Chrome(options=options)

browser.get(";)

This is just a sample code (even it does not work), and when I execute it, it starts my Chrome for Testing.

It closes with this error just after less than 1 second of opening it.

DevTools listening on ws://127.0.0.1:55431/devtools/browser/c71d8c52-305b-4d0e-a1e9-ac9d162a6e58
[14964:5104:0104/182047.170:ERROR:sandbox_win(791)] Sandbox cannot access executable. Check filesystem permissions are valid. See /+/refs/heads/main/docs/design/sandbox.md#lpac-file-system-permissions.: Access is denied. (0x5)
[14964:18156:0104/182047.345:ERROR:network_service_instance_impl(613)] Network service crashed, restarting service.

What am I doing wrong?

I wanted to make a automatic login bot with Python and Selenium, but I keep getting an Error.

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
browser = webdriver.Chrome(options=options)

browser.get("https://github.com/aahan0511")

This is just a sample code (even it does not work), and when I execute it, it starts my Chrome for Testing.

It closes with this error just after less than 1 second of opening it.

DevTools listening on ws://127.0.0.1:55431/devtools/browser/c71d8c52-305b-4d0e-a1e9-ac9d162a6e58
[14964:5104:0104/182047.170:ERROR:sandbox_win.cc(791)] Sandbox cannot access executable. Check filesystem permissions are valid. See https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/design/sandbox.md#lpac-file-system-permissions.: Access is denied. (0x5)
[14964:18156:0104/182047.345:ERROR:network_service_instance_impl.cc(613)] Network service crashed, restarting service.

What am I doing wrong?

Share Improve this question asked 12 hours ago Aahan SalechaAahan Salecha 12 bronze badges New contributor Aahan Salecha is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct. 2
  • The code is performing effectively in my testing. – Subir Chowdhury Commented 11 hours ago
  • Ger rid of all the options related code and leave just browser = webdriver.Chrome(). Now does it work? Are you running this on AWS or some other cloud/VM? – JeffC Commented 10 hours ago
Add a comment  | 

1 Answer 1

Reset to default 0

Few steps to try:

  1. Disable Sandbox Mode: Add the --no-sandbox argument to Chrome options:

    options.add_argument("--no-sandbox")

  2. Ensure ChromeDriver matches your Google Chrome version.

  3. Run the script with admin rights.

  4. Ensure the chromedriver.exe file has proper execution permissions.

  5. Reinstall Chrome: If the issue persists, reinstall Google Chrome to ensure a clean installation.

最新文章