Installation Guide for Google Chrome, ChromeDriver, and Selenium in a Python Virtual Environment

Kate Kuehl
3 min readOct 3, 2023

In the realm of web automation, Selenium is a renowned tool. You might need it to test or automate your UI work. To use it effectively with Google Chrome, certain setup steps are essential. This guide will walk you through these necessary preparations for your next project!

Table of Contents

- Installing Google Chrome
- Installing ChromeDriver
- Setting Up a Python Virtual Environment
- Installing Selenium
- Verifying Installation
- Troubleshooting

Installing Google Chrome

1. Visit the official download page:

Navigate to Google Chrome’s official website and download the appropriate version for your operating system.

2. Install the package:

  • For Windows: Run the installer and follow the on-screen instructions.
  • For Mac: Open the downloaded `.dmg` file and drag the Chrome application to the Applications folder.
  • For Linux: Depending on your distribution, use `dpkg` (for Debian/Ubuntu) or `rpm` (for Fedora/Red Hat):

sudo dpkg -i google-chrome-stable_current_amd64.deb # For Debian/Ubuntu
sudo rpm -i google-chrome-stable_current_x86_64.rpm # For Fedora/Red Hat sudo yum install ./google-chrome-stable_current_x86_64.rpm # Alternative

Installing ChromeDriver

1. Determine your Chrome version:

Open Google Chrome, click on the three vertical dots on the top right -> Help -> About Google Chrome. Note down the version number.

2. Download the appropriate ChromeDriver:

Visit the ChromeDriver download page and download the version that matches your Chrome version.

3. Extract and move ChromeDriver:

  • For Windows: Extract the downloaded ZIP file and move `chromedriver.exe` to a location in your system’s PATH or any directory.
  • For Mac/Linux: Extract the downloaded ZIP/tar file:

unzip chromedriver_win32.zip # For Windows
tar -xvf chromedriver_mac64.zip # For Mac
tar -xvf chromedriver_linux64.tar.gz # For Linux

Move the `chromedriver` to `/usr/bin/` or any location in your system’s PATH:

sudo mv chromedriver /usr/bin/

Setting Up a Python Virtual Environment

1. Check your Python version:

Determine your Python version with:

python --version

If you have both Python 2 and Python 3 installed, it might be:

python3 --version

2. Create a new virtual environment:

Use one of the following, based on your Python version:

python -m venv venv

OR

python3 -m venv venv

3. Activate the virtual environment:

  • For Windows:

.\venv\Scripts\activate

  • For Mac/Linux:

source venv/bin/activate

Your terminal or command prompt should now display `(venv)` at the start, indicating that the virtual environment is active.

Installing Selenium

With the virtual environment active, install Selenium:

pip install selenium

Verifying Installation

1. Verify Google Chrome:

Run `google-chrome` from the terminal (or cmd on Windows) or find Google Chrome in your applications and launch it.

2. Verify ChromeDriver:

Execute:

chromedriver --version

This should match the Google Chrome version you noted earlier.

3. Verify Selenium:

Run:

pip show selenium

This will display Selenium package details, confirming its installation in your virtual environment.

Troubleshooting

  • Ensure Google Chrome and ChromeDriver versions match.
  • If you encounter PATH issues, verify `chromedriver` is in a directory within your system’s PATH.
  • On Linux, if `chromedriver` has permission issues, grant it executable permissions: `chmod +x chromedriver`.
Graphic: Selenium and Python on Chrome

--

--