Chromedriver Autoinstaller
chromedriver-autoinstaller is a Python library that automatically downloads and installs the appropriate Chromedriver executable for the currently installed version of Google Chrome on your system. It supports Linux, MacOS, and Windows operating systems. The current version is 0.6.4 and the library is actively maintained, with a recent release in January 2024.
Warnings
- breaking Chrome v115+ introduced a new driver restructuring (Chrome-for-Testing), which broke older versions of `chromedriver-autoinstaller`'s ability to locate and download the correct driver.
- gotcha Running Chrome or ChromeDriver as the root user (administrator) on Linux is highly discouraged and can cause Chrome to crash, often resulting in 'DevToolsActivePort file doesn't exist' errors.
- gotcha When bundling applications with tools like `cx_Freeze` or PyInstaller, missing SSL-related DLLs (e.g., `libcrypto-1_1-x64.dll`, `libssl-1_1-x64.dll` on Windows) can prevent `chromedriver-autoinstaller` from downloading files, leading to SSL errors during installation.
- gotcha Be careful with package naming. The correct package name for this library is `chromedriver-autoinstaller`. Other similar-sounding packages like `chromedriver-autoinstall` or `chromedriver-autoinstaller-fix` exist on PyPI and may offer different functionality, bug fixes, or maintenance levels.
Install
-
pip install chromedriver-autoinstaller
Imports
- install
import chromedriver_autoinstaller chromedriver_autoinstaller.install()
Quickstart
import chromedriver_autoinstaller
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import os
# Ensure chromedriver is installed and up-to-date
chromedriver_autoinstaller.install()
# Set up Chrome options (e.g., headless mode for automation)
chrome_options = Options()
# chrome_options.add_argument('--headless') # Uncomment for headless browsing
# chrome_options.add_argument('--no-sandbox') # Recommended for Linux environments, especially in CI/CD
# Initialize the WebDriver
driver = webdriver.Chrome(options=chrome_options)
# Navigate to a website
driver.get("https://www.google.com")
# Print the page title to verify
print(f"Page title: {driver.title}")
# Close the browser
driver.quit()