debugpythonMajorpending
Debug: Python ModuleNotFoundError after pip install
Viewed 0 times
ModuleNotFoundErrorpipinstallvirtualenvimport
Error Messages
Problem
You pip install a package but Python says ModuleNotFoundError when you import it.
Solution
Common causes and fixes:
Fix: Use python3 -m pip install <package> to ensure pip matches your Python
Fix: which python && which pip — they should point to the same env
Fix: Check PyPI page for the correct import name
Fix: !which python inside the notebook to verify
- 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
- 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
- Package name differs from import name: pip install Pillow, but import PIL
Fix: Check PyPI page for the correct import name
- 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.