Python Modules & Packages
Python pip Package Manager
pip is Python's official package manager — a terminal command that downloads and installs third-party libraries from PyPI so you can reuse other people's code.
What Is pip?
The Python standard library covers a lot, but for things like web frameworks, data science, or automation you need external packages. pip (which stands for "pip installs packages") fetches these from the Python Package Index, PyPI, and installs them for you.
Installing a Package
Open your terminal and run pip install followed by the package name. You can also install a specific version if your project needs one exactly.
pip install requests
pip install pandas==2.2.0Uninstalling a Package
If you no longer need a library, remove it cleanly with pip uninstall so it does not clutter your environment.
pip uninstall requestsListing Installed Packages
pip list shows every package currently installed along with its version — useful for checking what a project already has available.
pip listpip freeze and requirements.txt
pip freeze prints your installed packages in a format that can be saved into a requirements.txt file. Anyone cloning your project can then install the exact same versions with one command, which is essential for teamwork and deployment.
pip freeze > requirements.txt
pip install -r requirements.txtAlways create requirements.txt inside a virtual environment, not your global Python install, so it only lists packages your project actually needs.
| Command | Purpose |
|---|---|
| pip install <pkg> | Install the latest version |
| pip install <pkg>==1.2.0 | Install an exact version |
| pip uninstall <pkg> | Remove a package |
| pip list | Show installed packages |
| pip freeze | Print installed packages with versions |
| pip install -r requirements.txt | Install everything listed in the file |
Frequently Asked Questions
Do I need to install pip separately?+
No. Since Python 3.4, pip comes bundled with every standard Python installation, so it is ready to use as soon as Python is installed.
What is the difference between pip list and pip freeze?+
pip list gives a human-readable table, while pip freeze outputs a package==version format that can be pasted straight into requirements.txt.
Why do my teammates need requirements.txt?+
It guarantees everyone installs the exact same package versions, avoiding "it works on my machine" bugs caused by version mismatches.
