Selenium: chromedriver executable needs to be in PATH?

Older Selenium versions raise this error when they can't find the ChromeDriver executable on your system PATH:

selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home

To fix it, upgrade Selenium. Recent versions include Selenium Manager, which can find or download the ChromeDriver version that matches your Chrome browser.

Fix the error by upgrading Selenium

Upgrade Selenium, then check the installed version:

python -m pip install --upgrade selenium
python -c "import selenium; print(selenium.__version__)"

Selenium Manager was added in Selenium 4.6, but Selenium 4.11 or later is required to download ChromeDriver for Chrome 115 and later. Use the latest release if you can.

Then start Chrome without a driver path:

from selenium import webdriver

driver = webdriver.Chrome()
driver.get("https://www.scrapingbee.com/")
print(driver.title)
driver.quit()

The first run can take a few seconds while Selenium Manager downloads ChromeDriver. Later runs use the cached copy. With Selenium Manager, you usually don't need the webdriver-manager package.

Set the ChromeDriver executable path yourself

Set the path yourself if Selenium Manager can't download drivers, for example on a machine without internet access or behind a strict firewall:

  1. Check your Chrome version at chrome://version.

  2. On Chrome for Testing, download the chromedriver ZIP file whose major, minor and build numbers match your Chrome. Only the last number can differ: for example, Chrome 154.0.8037.98 works with ChromeDriver 154.0.8037.92. If your build isn't listed on the dashboard, look it up in the latest patch versions per build file. Choose the file for your operating system: win64 (or win32 for 32-bit Chrome) on Windows, mac-arm64 on Apple silicon Macs, mac-x64 on Intel Macs, linux64 on x86-64 Linux, and linux-arm64 on ARM64 Linux. On Linux, run uname -m to check: x86_64 means x86-64, and aarch64 means ARM64.

  3. Extract the ZIP file. The executable is inside a folder, for example chromedriver-mac-arm64/chromedriver or chromedriver-win64\chromedriver.exe.

  4. On macOS and Linux, if Selenium reports that the executable "may have wrong permissions", make it executable:

    chmod +x /path/to/chromedriver
    

    On macOS, if Selenium reports that the driver "unexpectedly exited" with status code -9, macOS may have blocked the downloaded file. Remove the quarantine flag:

    xattr -d com.apple.quarantine /path/to/chromedriver
    
  5. Pass the path to the extracted executable with a Service object:

    from selenium import webdriver
    from selenium.webdriver.chrome.service import Service
    
    service = Service(executable_path="/path/to/chromedriver")  # on Windows: r"C:\path\to\chromedriver.exe"
    driver = webdriver.Chrome(service=service)
    

In Selenium 4.26 or later for Python, you can also set the path in the SE_CHROMEDRIVER environment variable instead of in code.

Don't pass executable_path to webdriver.Chrome() directly. Selenium 4 deprecated that argument, and Selenium 4.10 removed it, so it now raises TypeError: WebDriver.__init__() got an unexpected keyword argument 'executable_path'.

Common errors

  • SessionNotCreatedException: This version of ChromeDriver only supports Chrome version …: your ChromeDriver and Chrome versions don't match. A common cause is an old chromedriver on your PATH, or a fixed executable path, after Chrome updated itself. Selenium can use a ChromeDriver it finds on PATH even when the version doesn't match (it only logs a warning), so remove the old driver or replace it with the matching version.
  • NoSuchDriverException: Unable to obtain driver for chrome: Selenium couldn't get a driver. Check whether the machine can reach the download servers, and whether the path in your Service object points to a file that exists.

Skip driver management with ScrapingBee

If you only need the rendered HTML of a page, ScrapingBee runs a headless browser for you, so there's no ChromeDriver to install or update. Install the ScrapingBee Python SDK with python -m pip install scrapingbee:

from scrapingbee import ScrapingBeeClient

client = ScrapingBeeClient(api_key="YOUR-API-KEY")
response = client.html_api("https://www.scrapingbee.com/")
print(response.text)

Related Selenium web scraping questions: