# ModuleNotFoundError: No module named 'psycopg2'

- **ID:** `python/sqlalchemy-missing-driver`
- **Domain:** python
- **Category:** install_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The database driver for PostgreSQL is not installed in the Python environment.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **Install psycopg2 using pip** (95% success)
   ```
   pip install psycopg2-binary
   ```
2. **Switch to a different driver like asyncpg** (85% success)
   ```
   # Change connection string to use asyncpg
engine = create_engine('postgresql+asyncpg://user:pass@localhost/db')
   ```

## Dead Ends

- **Installing a different driver without changing the connection string** — The connection string still references psycopg2. (70% fail)
- **Using a virtual environment without activating it** — The module is installed but not accessible. (80% fail)
