## TL;DR
The stopwords corpus is not downloaded, or it sits in a directory NLTK is not searching. Fix it by downloading the resource once, or by pointing NLTK at the directory that already has it via the `NLTK_DATA` environment variable.

```text
LookupError: Resource 'stopwords' not found.
```

## When to use
- Code runs on a fresh machine, container, or CI runner
- `NLTK_DATA` is set in one environment but not another
- Corpora were downloaded to a custom directory

## When not to use
- The download itself fails or the files are corrupted (re-download with force)
- A non-NLTK tokenizer is missing its model (thats a different package)
- You want zero downloads at runtime (vendor the data into the image instead)

## Steps

1. Download the missing resource:

```python
import nltk
nltk.download("stopwords")
```
Expected output: the downloader reports the package installed. This fixes the large majority of cases.

2. Check where NLTK actually looks, and where the data landed:

```python
import nltk
print(nltk.data.path)
```
Expected output: a list of searched directories. If the corpus downloaded to a path not in this list, the lookup still fails.

3. Point NLTK at the right directory with the environment variable before importing:

```bash
export NLTK_DATA=/path/to/nltk_data
```
Expected output: the next run finds the resource. This is the standard fix for containers where data is baked into a non-default path.

4. Or append the path in code when you cannot control the environment:

```python
import nltk
nltk.data.path.append("/path/to/nltk_data")
```
Expected output: lookups succeed for the rest of the process. Do this before the first corpus access.

## Variant phrasings

### Resource 'punkt' not found
Identical fix, different resource name. Download `punkt` or set the path the same way.

### LookupError only in production, works locally
Production lacks the downloaded data or the env var. Bake the download into the image build so runtime never depends on it.

## Why it happens
NLTK splits code from data URIs the pip package ships no corpora. The data downloader writes to a default location that varies by OS and user, and the lookup searches a fixed list of paths. Any mismatch between where the data was downloaded and where the running process looks produces this error, even when the files exist on disk.

## Edge cases
- In locked-down environments the downloader cannot reach the network. Pre-download during the image build instead.
- Multiple Python environments on one machine each need the data visible, or each needs its own `NLTK_DATA`.
- `nltk.download()` without arguments opens an interactive GUI picker; always name the resource in scripts.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_7e2sEkRjeeQndgBH86vHiQ
