scan-build
raw JSON → 3.0.0 verified Mon Apr 27 auth: no python
A static code analyzer tool for Clang that uses compilation databases (compile_commands.json). Version 3.0.0 is the latest, requiring Python >=3.10 and dropping support for 3.6-3.9. The package is maintained with modern tooling (hatchling, ruff, pytest).
pip install scan-build Common errors
error ModuleNotFoundError: No module named 'scan-build' ↓
cause Attempting to import using the hyphenated package name instead of the underscore module name.
fix
Use 'from scan_build import ...' (underscore).
error scan-build: error: compilation database not found at compile_commands.json ↓
cause The compilation database file is missing or not generated.
fix
Generate compile_commands.json (e.g., using CMake or bear) before running scan-build.
error ImportError: cannot import name 'Analyze' from 'scan_build' (unknown location) ↓
cause Incorrect import path or old version of scan-build that may not expose Analyze.
fix
Ensure scan-build >=3.0.0 is installed (pip install scan-build>=3.0.0) and import from scan_build module.
Warnings
breaking Version 3.0.0 drops support for Python 3.6-3.9. Update to Python >=3.10. ↓
fix Upgrade Python to 3.10 or later, and update scan-build to 3.0.0.
deprecated The old CLI entry point 'scan-build' (Perl-based) is not part of this Python package. Only the Python API is provided. ↓
fix Use the Python API from scan_build module instead of CLI.
gotcha The module name is scan_build (underscore), not scan-build (hyphen). Importing with hyphen fails. ↓
fix Use 'from scan_build import ...'
gotcha The package requires a compilation database (compile_commands.json). It does not work without one. ↓
fix Generate compile_commands.json using tools like bear or CMake with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON.
Imports
- Analyze wrong
from scan-build import Analyzecorrectfrom scan_build import Analyze
Quickstart
from scan_build import Analyze
from scan_build.report import Report
# Analyze using compile_commands.json
analyzer = Analyze(compilation_database='compile_commands.json')
report = analyzer.run()
print(report.summary())