# ImportError: cannot import name 'cm' from 'matplotlib' (unknown location)

- **ID:** `python/matplotlib-missing-colormap-module`
- **Domain:** python
- **Category:** module_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A corrupted or partial installation of matplotlib where the cm module is missing, or a naming conflict with a local file named matplotlib.py.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.7 | active | — | — |
| 3.8 | active | — | — |

## Workarounds

1. **Check for local matplotlib.py file and rename it** (85% success)
   ```
   import sys; print([p for p in sys.path if 'matplotlib.py' in p])
   ```
2. **Perform a clean reinstall in a new virtual environment** (95% success)
   ```
   python -m venv newenv; source newenv/bin/activate; pip install matplotlib
   ```

## Dead Ends

- **Reinstalling matplotlib with pip install --upgrade matplotlib** — If the issue is a local file conflict, reinstallation may not help. (60% fail)
- **Importing matplotlib.cm instead of from matplotlib import cm** — Both should work; if cm is missing, both fail. (90% fail)
