PIP stands for “Pip Installs Packages” (or “Preferred Installer Program”).
It is the official package manager for Python used to install, update, and manage external libraries and dependencies that are not part of the Python standard library.
PIP makes it easy to extend Python’s functionality by downloading prebuilt packages from the Python Package Index (PyPI) — the official online repository of Python software.
🔹 Key Features of PIP
| Feature | Description |
|---|---|
| Install Packages | Installs external Python libraries from PyPI or other sources. |
| Uninstall Packages | Removes installed libraries. |
| Upgrade Packages | Updates libraries to the latest version. |
| List Installed Packages | Displays all installed libraries. |
| Freeze Requirements | Generates a requirements.txt file for sharing dependencies. |
🔹 Checking if PIP is Installed
You can check your PIP version using:
pip --versionOutput Example:
pip 24.0 from C:\Python312\Lib\site-packages\pip (python 3.12)If you see this, it means PIP is correctly installed.
🔹 Installing a Package
To install a package (e.g., requests):
pip install requestsOutput:
Successfully installed requests-2.31.0After installation, you can import it in Python:
import requests🔹 Installing a Specific Version
pip install numpy==1.25.0To upgrade an existing package:
pip install --upgrade numpy🔹 Uninstalling a Package
pip uninstall requests🔹 Listing Installed Packages
pip listOutput Example:
Package Version
----------- -------
numpy 1.25.0
pandas 2.2.1
requests 2.31.0🔹 Searching for Packages
(Note: In newer versions, use PyPI’s website instead.)
pip search flask🔹 Generating requirements.txt
To create a dependency list for your project:
pip freeze > requirements.txtExample content:
Flask==3.0.0
requests==2.31.0
numpy==1.25.0To install all dependencies from the file:
pip install -r requirements.txt🔹 Upgrading PIP
It’s recommended to keep PIP updated:
python -m pip install --upgrade pip🔹 Using PIP for Virtual Environments
When working inside a virtual environment, pip installs packages only for that environment, keeping your system Python clean.
Example:
python -m venv myenv
source myenv/bin/activate # Linux/macOS
myenv\Scripts\activate # Windows
pip install flask🔹 Commonly Used PIP Commands
| Command | Description |
|---|---|
pip install package_name | Install a package |
pip uninstall package_name | Uninstall a package |
pip install --upgrade package_name | Upgrade a package |
pip show package_name | Show detailed info about a package |
pip list | List installed packages |
pip freeze > requirements.txt | Save dependencies to a file |
pip install -r requirements.txt | Install packages from a file |
pip cache purge | Clear the pip cache |
python -m pip install --upgrade pip | Upgrade pip itself |
🔹 Example: Installing and Using a Package
pip install requestsimport requests
response = requests.get("https://api.github.com")
print(response.status_code)Output:
200🔹 In Summary
| Feature | Description |
|---|---|
| Full Form | Pip Installs Packages |
| Purpose | Manage Python libraries and dependencies |
| Default Repository | PyPI (https://pypi.org) |
| Included Since | Python 3.4+ (automatically installed) |
| Key File | requirements.txt for dependency management |
✅ In short:
PIP is Python’s official package manager, used to install, update, and manage third-party libraries from PyPI, making Python development faster, flexible, and modular.
