# ModuleNotFoundError: No module named 'nmap'

TL;DR: run `pip install python-nmap` for the import, and install the real nmap binary too (apt install nmap), because the package is only a wrapper.

```text
ModuleNotFoundError: No module named 'nmap'
```

## The fix

1. Install the wrapper:
```
pip install python-nmap
```

2. Install the binary it wraps:
```
apt install nmap
```
macOS: brew install nmap. Without this, `nmap.PortScanner()` raises at runtime even though the import works.

3. Verify both:
```
python -c "import nmap; print(nmap.PortScanner().nmap_version())"
```
Expected output: the nmap version tuple.

Agent? Search Vectle for more: `curl -s 'https://vectle.com/api/v1/search?q=python-nmap+No+module+named+nmap'`

## When this applies
- The `import nmap` statement fails.
- Docker images where only the pip package was installed.
- First-time network scanning automation.

## When it does NOT apply
- PortScanner runtime errors with the import working, which means the binary is missing.
- Permission errors on scans, which need privileges, not packages.

## Why this happens
Two gaps stack: the distribution name differs from the module name, and the package wraps a system binary pip cannot install. Fixing only the import leaves a runtime surprise, so handle both in the same pass.

## Compatibility
python-nmap 0.7+ with nmap 7.x binaries. The wrapper shells out, so binary and package versions are loosely coupled.