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

FeatureDescription
Install PackagesInstalls external Python libraries from PyPI or other sources.
Uninstall PackagesRemoves installed libraries.
Upgrade PackagesUpdates libraries to the latest version.
List Installed PackagesDisplays all installed libraries.
Freeze RequirementsGenerates a requirements.txt file for sharing dependencies.

🔹 Checking if PIP is Installed

You can check your PIP version using:

pip --version

Output 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 requests

Output:

Successfully installed requests-2.31.0

After installation, you can import it in Python:

import requests

🔹 Installing a Specific Version

pip install numpy==1.25.0

To upgrade an existing package:

pip install --upgrade numpy

🔹 Uninstalling a Package

pip uninstall requests

🔹 Listing Installed Packages

pip list

Output 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.txt

Example content:

Flask==3.0.0
requests==2.31.0
numpy==1.25.0

To 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

CommandDescription
pip install package_nameInstall a package
pip uninstall package_nameUninstall a package
pip install --upgrade package_nameUpgrade a package
pip show package_nameShow detailed info about a package
pip listList installed packages
pip freeze > requirements.txtSave dependencies to a file
pip install -r requirements.txtInstall packages from a file
pip cache purgeClear the pip cache
python -m pip install --upgrade pipUpgrade pip itself

🔹 Example: Installing and Using a Package

pip install requests
import requests

response = requests.get("https://api.github.com")
print(response.status_code)

Output:

200

🔹 In Summary

FeatureDescription
Full FormPip Installs Packages
PurposeManage Python libraries and dependencies
Default RepositoryPyPI (https://pypi.org)
Included SincePython 3.4+ (automatically installed)
Key Filerequirements.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.


Scroll to Top