Installing packages with pip
Python’s strength comes from its ecosystem. The standard library gives us a solid foundation, but real programs almost always rely on third-party packages to add capabilities without reinventing them. pip exists to make that ecosystem usable in practice, letting us pull in external code and build on it safely.
What a Python package is
A Python package is a bundle of code designed to be reused. It usually provides new functions, classes, or tools that solve a specific problem well, such as working with HTTP, data formats, or dates.
Packages live outside our own project code. We install them once into a Python environment, and then import and use them like any other module.
Installing third-party packages using pip
pip is Python’s package installer. We use it from the command line to download and install packages from the Python Package Index.
A minimal install command looks like this:
pip install requests
This tells pip to fetch the package and make it available to our Python interpreter.
Installing specific package versions
Sometimes we need a specific version of a package, not just the latest one. pip lets us request an exact version explicitly.
pip install requests==2.31.0
Version pinning is common when we want predictable behavior across machines or deployments.
Listing installed packages
Once packages are installed, we can ask pip what is currently available in the environment.
pip list
This shows installed package names and their versions, giving us a snapshot of what our Python environment contains.
Using installed packages in a Python program
After installation, a package is used by importing it in a Python file. From that point on, it behaves like any other module.
import requests
response = requests.get("https://example.com")
print(response.status_code)
At this stage, the important thing is recognition: installation happens with pip, usage happens with import, and the package becomes part of the program’s building blocks.
Conclusion
We now know what Python packages are, how pip installs them, how to control versions, how to inspect what’s installed, and how installed packages show up in real code. That’s the full mental model needed to start using third-party libraries confidently and to explore Python’s wider ecosystem as our programs grow.