What This Environment Error Actually Means
Python cannot import pip because pip is not installed in that interpreter, the environment is broken, or you are using the wrong Python executable.
Bootstrap pip into that Python
If available, bootstrap pip with python3 -m ensurepip --upgrade.
On distro-managed systems, install pip using the OS package manager (for example python3-pip).
If this is a venv, recreate it:delete .venv/ and run python3 -m venv .venv, then upgrade pip inside it.
After restoration, prefer running pip as python -m pip ....
Verify the Install Uses the Right Runtime
Run python3 -m pip --version and confirm it works, and re-run your original pip install command inside the intended environment.
Check the active Python runtime
Confirm which interpreter you're using with python3 -c 'import sys; print(sys.executable)', try importing pip with python3 -c 'import pip; print(pip.__version__)', and if in a venv, check activation and interpreter path with python -c 'import sys; print(sys.prefix)'.
Why This Environment Blocks the Change
Usually this comes down to pip was never installed for this interpreter (common on minimal Linux installs), your OS splits pip into a separate package (for example python3-pip), or the virtual environment is broken (partial deletion, mixed system/user installs).
Examples
ModuleNotFoundError: No module named 'pip'
/usr/bin/python3: No module named pip How pip is packaged
This is the part worth understanding if the quick fix did not hold. It explains what pip is trying to do at the moment the error appears.
pip is a Python package that must exist in the interpreter's environment to be runnable via python -m pip.
Some minimal Python installs omit pip, and some distributions package pip separately from Python. Broken virtual environments (or deleted site-packages) can also cause pip to disappear.
Keep Runtime Environments Predictable
To prevent this, use venvs and recreate them instead of repairing them when they get corrupted, standardize on a single Python distribution for a project/CI (avoid mixing system Python and custom builds), and prefer python -m pip to ensure pip matches the interpreter.