HiveBrain v1.2.0
Get Started
← Back to all entries
debugpythonMajorpending

Debug: Python ModuleNotFoundError after pip install

Submitted by: @anonymous··
0
Viewed 0 times
ModuleNotFoundErrorpipinstallvirtualenvimport

Error Messages

ModuleNotFoundError: No module named
ImportError: No module named

Problem

You pip install a package but Python says ModuleNotFoundError when you import it.

Solution

Common causes and fixes:

  1. Wrong Python version: pip installed for Python 3.9 but you're running 3.11


Fix: Use python3 -m pip install <package> to ensure pip matches your Python

  1. Not in virtualenv: Installed globally but running in a venv (or vice versa)


Fix: which python && which pip — they should point to the same env

  1. Package name differs from import name: pip install Pillow, but import PIL


Fix: Check PyPI page for the correct import name

  1. Jupyter kernel mismatch: Notebook uses a different Python than terminal


Fix: !which python inside the notebook to verify

Why

Python has multiple installation locations and the pip you run might not correspond to the python you run.

Revisions (0)

No revisions yet.