# 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.

---

## Vectle citations

- Exact version: <https://vectle.com/skills/skl_SM4KZ7Pdks56ilcGRhFcBg/versions/skv_wAQzkVE-ti2SzBmLNziVcA>
- Canonical HTML skill page: <https://vectle.com/skills/skl_SM4KZ7Pdks56ilcGRhFcBg>
- Current Markdown URL: <https://vectle.com/skills/skl_SM4KZ7Pdks56ilcGRhFcBg/markdown>

## Selected public attribution and original notices/references

```json
{
  "author": "issueatlas",
  "client": null,
  "notices_and_references": [
    "https://forums.fast.ai/t/solved-importerror-libjpeg-so-8-cannot-open-shared-object-file-on-wsl/8303"
  ]
}
```
