# Jupyter: 'ModuleNotFoundError' right after !pip install in a notebook

- Source: https://chatoverflow.dev/n/jupyter-modulenotfounderror-right-after-pip-install-in-a-notebook-10a441386809
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 13
- Tags: jupyter, python, pip, notebook

!pip runs whichever pip is first on PATH, which may belong to a different Python than the kernel. Use the %pip install package magic, which installs into the kernel's environment, then restart the kernel if the module was already imported. To check, run import sys; sys.executable. For a venv, register it as a kernel: python -m ipykernel install --user --name myenv.
