Install Selenium with Python: Complete Setup

Selenium 12 min min read Updated: Nov 16, 2026 Beginner
Install Selenium with Python: Complete Setup
Beginner Topic 3 of 5

What You Need

ItemNotes
Python 3.10 or newerRecent Selenium releases dropped older versions. Download from python.org
A browserGoogle Chrome is easiest for beginners. Firefox and Edge also work
Code editorVS Code (free) or PyCharm Community (free)
InternetSelenium Manager downloads drivers on first run

Step 1: Check Python

bash python --version # or on macOS/Linux python3 --versio

You should see Python 3.10 or higher. On Windows tick Add Python to PATH during installation.

Step 2: Create a Project Folder and Virtual Environment

A virtual environment keeps the packages of one project separate from other projects.

bash mkdir selenium-course cd selenium-course # create python -m venv .venv # activate: Windows (PowerShell) .venv\Scripts\Activate.ps1 # activate: Windows (cmd) .venv\Scripts\activate.bat # activate: macOS / Linux source .venv/bin/activate

When active, your terminal prompt shows (.venv).

Step 3: Install Selenium and pytest

bash pip install selenium pytest pip list

Create a file requirements.txt so others can install the same packages:

bash pip freeze > requirements.txt # later, on another computer pip install -r requirements.txt

Step 4: Verify the Installation

python import selenium print(selenium.__version__)

Step 5: Quick Browser Test

python from selenium import webdriver driver = webdriver.Chrome() # Selenium Manager finds or downloads chromedriver driver.get("https://www.selenium.dev") print(driver.title) driver.quit()

A Chrome window opens, loads the site, prints the title and closes. If this works your setup is complete.

Common Problems and Fixes

ProblemFix
ModuleNotFoundError: No module named 'selenium'Activate the virtual environment, then pip install selenium. In your editor select the .venv interpreter
'python' is not recognizedReinstall Python with *Add to PATH*, or use py on Windows
Driver download failsCheck internet or proxy settings. Corporate networks may block downloads; set HTTPS_PROXY
Version mismatch errors from an old driverRemove old chromedriver from your PATH and let Selenium Manager choose
Script runs but window closes at onceThat is normal: the script ended. driver.quit() closes the browser. Add input() to pause while learning

Suggested Folder Structure

text selenium-course/ .venv/ requirements.txt first_test.py tests/ pages/
Editors: In VS Code install the Python extension. In PyCharm the virtual environment is created for you when you start a new project.

Conclusion

Install Python, create a virtual environment, run pip install selenium pytest and open a browser from a short script. Selenium Manager handles the driver for you.

Quick Summary: python -m venv, pip install selenium pytest, webdriver.Chrome() just works.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators