# How to fix ImportError: libjpeg.so.8: cannot open shared object file: No such file or directory

The system JPEG library Pillow was built against is missing. On Debian/Ubuntu: `sudo apt-get install libjpeg-turbo8` (or libjpeg8). Easiest robust fix: reinstall Pillow from a wheel so it bundles its own libs: `pip install --force-reinstall --no-cache-dir pillow`.

## The exact error

```text
ImportError: libjpeg.so.8: cannot open shared object file: No such file or directory
```

## Fix it

1. `sudo apt-get install libjpeg-turbo8` (Debian/Ubuntu) or the equivalent libjpeg package.
   Expected: libjpeg.so.8 exists on the system

2. Or reinstall Pillow as a wheel: `pip install --force-reinstall --no-cache-dir pillow`.
   Expected: Pillow bundles its own libs

3. Verify: open a JPEG with PIL and call .load() on it.
   Expected: image loads, prints ok

## When this applies

Pillow import or JPEG open fails on libjpeg.so.8 missing (WSL, Docker, minimal images)

## When this does NOT apply

Pillow not installed at all

## Versions

Linux, Pillow built from source / minimal envs

## Why it happens

Source-built Pillow links the system libjpeg; the runtime image lacks it.

## Edge cases

Alpine/musl needs the apk libjpeg-turbo package; prefer musl wheels when available.
