ImportError: cannot import name 'Reporter' from 'coverage.report'
Fixes ImportError for Reporter from coverage.report by upgrading the importing tool or pinning coverage below 7. Use when an old IDE plugin or pytest-cov meets coverage 7. Not for display_covered errors.
TL;DR
Upgrade the tool that imports Reporter (often an old PyCharm pytest plugin or pinned pytest-cov), or align coverage to a version that still has it. Reporter was removed from coverage.report in coverage 7.
ImportError: cannot import name 'Reporter' from 'coverage.report'Fix it
- Find who imports it. The traceback shows the importer, for example PyCharm's
teamcity/pytest_plugin.pydoingfrom coverage.report import Reporter.
- Expected: the file and line are named in the traceback.
- Upgrade the importer. Update PyCharm, or run
python -m pip install -U pytest-cov coverage.
- Expected: the new importer no longer references the removed name.
- If you cannot upgrade the importer, pin coverage to 6.x:
python -m pip install "coverage<7".
- Expected:
Reporterimports fine again.
When this applies
- Old IDE plugins (PyCharm 2020-era) or old pytest-cov with coverage 7.
- The traceback literally says
from coverage.report import Reporter.
When it does not apply
- If the missing name is
display_coveredfromcoverage.results, that is the sibling issue with its own fix.
Tool compatibility
coverage 7 removed Reporter from coverage.report. PyCharm 2020.x and old pytest-cov predate the removal.
Why it happens
coverage 7 refactored its reporting internals and dropped the Reporter class. Anything importing it directly breaks on upgrade.
Edge cases
- JetBrains fixed this in later PyCharm releases; updating the IDE is the cleanest fix (see PY-40980).
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.