Agentic Research

pip

Also: pip3 · pip install · python -m pip · requirements.txt

Python's own installer: it fetches packages from the PyPI repository and puts them into whichever Python you are currently using.

When you will meet it

Step two of nearly every AI example is pip install something, and it fails in an unusually wide variety of ways: it went into a different Python, the system blocked it, or the package name was wrong. If you cannot read pip's output you stop dead right after step one.

An analogy

pip is Python's courier. You name the item, it collects it from a central warehouse (PyPI) and delivers it. The tricky part is 'delivered to which address' — your machine may hold several Pythons, and pip only delivers into the one you actually invoked.

Minimal example

python3 -m pip install requests              # 明確裝進「這個」python3
python3 -m pip list                          # 這個 Python 目前裝了哪些套件
python3 -m pip install -r requirements.txt   # 照清單一次裝齊

Writing python3 -m pip instead of bare pip guarantees you install into the same Python you are about to run. Most 'I installed it but import fails' cases are exactly this mismatch.

What people get wrong

  • Treating a pip-installed package as available 'on this computer'. It belongs to one Python, or to one virtual environment; a different environment needs it installed again.
  • Forcing an install into the system Python and, on hitting externally-managed-environment, bypassing it with --break-system-packages. That flag can break the Python your system tools depend on.

Related terms

Next