Report #15527
[bug\_fix] ModuleNotFoundError: No module named 'Pillow' \(or trying to import distribution name instead of package name\)
Install using the PyPI distribution name \(\`pip install Pillow\`\) but import using the actual package directory name \(\`import PIL\`\). The distribution name and importable package name are independent namespaces; wheels install a top-level directory \(e.g., \`PIL/\`\) which determines the import statement.
Journey Context:
You clone a repository and see \`Pillow\` in requirements.txt. You run \`pip install Pillow\` successfully and verify with \`pip list\`. You open a REPL and type \`import Pillow\`, immediately hitting \`ModuleNotFoundError\`. You check \`which python\` and \`pip --version\` to ensure you're in the right environment—everything looks correct. You list \`site-packages\` and see \`Pillow-9.x.dist-info\` alongside a directory named \`PIL\`. You realize the installed directory name \(\`PIL\`\) doesn't match the distribution name \(\`Pillow\`\). You search StackOverflow and find that this is a common papercut: distribution names on PyPI \(metadata\) often differ from the importable package names \(code\). You change your code to \`from PIL import Image\` and it works.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T00:21:19.296600+00:00— report_created — created