Python PIP
Python · Tooling & Errors
Theory
pip is the standard tool for installing third-party Python packages. Running pip install pandas in a terminal downloads pandas from PyPI, the Python Package Index, along with any packages it depends on, and installs them into the active Python environment. You can pin a version (pip install pandas==2.2.0 style), upgrade (pip install --upgrade pandas), remove (pip uninstall pandas) and see what is installed (pip list).
Teams record a project's dependencies in a requirements.txt file. pip freeze > requirements.txt writes the exact installed versions, and pip install -r requirements.txt recreates the same set on another machine. Using python -m pip install ... makes sure the package goes into the same Python you will run, which avoids the common 'installed it but import fails' problem.
Why we use it
Python's real power is its ecosystem - pandas, NumPy, scikit-learn and thousands more. pip lets you add any of them with one command and reproduce the same setup on any computer.
When to use it
Use pip in a terminal (not inside a .py script) whenever you need a library, ideally inside a virtual environment. Some teams use tools like conda, poetry or uv instead, but they solve the same problem.
How it works
- pip install pandas
- Already installed? Yes: Report 'Requirement already satisfied'. No: Look up pandas on PyPI.
- Download pandas and its dependencies
- Install them into the active environment
- import pandas now works
Syntax
pip install package_nameExample
pip install pandas numpy matplotlibKey points
- Packages are pulled from PyPI (Python Package Index)
- requirements.txt lists project dependencies
- pip freeze shows exact installed versions
- python -m pip installs into the same Python you run
- Install inside a virtual environment, not system-wide