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:
Check your Chrome version at
chrome://version.On Chrome for Testing, download the
chromedriverZIP 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(orwin32for 32-bit Chrome) on Windows,mac-arm64on Apple silicon Macs,mac-x64on Intel Macs,linux64on x86-64 Linux, andlinux-arm64on ARM64 Linux. On Linux, rununame -mto check:x86_64means x86-64, andaarch64means ARM64.Extract the ZIP file. The executable is inside a folder, for example
chromedriver-mac-arm64/chromedriverorchromedriver-win64\chromedriver.exe.On macOS and Linux, if Selenium reports that the executable "may have wrong permissions", make it executable:
chmod +x /path/to/chromedriverOn 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/chromedriverPass the path to the extracted executable with a
Serviceobject: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 oldchromedriveron yourPATH, or a fixed executable path, after Chrome updated itself. Selenium can use a ChromeDriver it finds onPATHeven 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 yourServiceobject 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)