How to Install coverage in Python
Code coverage measurement for Python
pip install coverage
What is coverage?
Code coverage measurement for Python
Coverage.py measures code coverage, typically during test execution. It uses the code analysis tools and tracing hooks provided in the Python standard library to determine which lines are executable, and which have been executed.
Coverage.py runs on these versions of Python:
Python 3.10 through 3.15 alpha, including free-threading. PyPy3 versions 3.10 and 3.11.
Quick Start
Minimal example to get started with coverage:
import coverage
print(coverage.__version__)
Installation
pip (standard)
pip install coverage
Virtual environment (recommended)
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install coverage
pip3
pip3 install coverage
conda
conda install -c conda-forge coverage
Poetry
poetry add coverage
Verify the Installation
After installing, confirm the package is available:
python -c "import coverage; print(coverage.__version__)"
If this prints a version number, installation succeeded. If you see a ModuleNotFoundError, see the errors section below.
Installation Errors
Common errors when installing coverage with pip.
ModuleNotFoundError: No module named 'coverage'
Cause: The package is not installed in the current Python environment.
Fix: Run pip install coverage. If using a virtual environment, ensure it is activated first.
ModuleNotFoundError: No module named 'coverage' (installed but still failing)
Cause: pip installed the package into a different Python than the one running your script.
Fix: Use python -m pip install coverage to install into the interpreter you are running.
ImportError: cannot import name 'X' from 'coverage'
Cause: The function or class does not exist in the installed version.
Fix: Check the version with pip show coverage and upgrade with pip install --upgrade coverage.
pip: command not found
Cause: pip is not in PATH or Python was not added to PATH during installation.
Fix: Try python -m pip install coverage. On macOS/Linux try pip3.
PermissionError: [Errno 13] Permission denied
Cause: No write access to the system Python package directory.
Fix: Use a virtual environment, or add --user: pip install --user coverage
SSL: CERTIFICATE_VERIFY_FAILED
Cause: pip cannot verify PyPI's SSL certificate — common behind corporate proxies.
Fix: Try: pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org coverage
Recent Releases
| Version | Released |
|---|---|
7.13.5 latest |
2026-03-17 |
7.13.4 |
2026-02-09 |
7.13.3 |
2026-02-03 |
7.13.2 |
2026-01-25 |
7.13.1 |
2025-12-28 |
Manage coverage
Upgrade to latest version
pip install --upgrade coverage
Install a specific version
pip install coverage==7.13.5
Uninstall
pip uninstall coverage
Check what is installed
pip show coverage