Python PIP

📦 Python PIP (Complete Guide)

PIP stands for:

Package Installer for Python

It is used to install, update, and remove Python libraries and packages from PyPI (Python Package Index).


✔️ Check if PIP is Installed

Open your Command Prompt / Terminal and type:

pip --version

Example output:

pip 24.0 from C:\Python\Lib\site-packages

🧩 Installing Packages with PIP

To install a Python package:

pip install package_name

Example:

pip install requests

🔄 Upgrade a Package

pip install --upgrade package_name

Example:

pip install --upgrade numpy

❌ Uninstall a Package

pip uninstall package_name

Example:

pip uninstall pandas

📋 Show Installed Packages

pip list

🔍 Search for Package

pip search keyword

Example:

pip search machine learning

📁 Installing from requirements.txt

Often in real projects (e.g., Django), you will see a file named requirements.txt.

It contains a list of required packages for a project.

Example file content:

numpy
pandas==1.3.5
matplotlib>=3.0

To install everything:

pip install -r requirements.txt

📤 Freeze Installed Packages

This saves your installed package versions into a file:

pip freeze > requirements.txt

💡 Useful PIP Commands Table

Command Description
pip --version Check pip version
pip install pkg Install package
pip uninstall pkg Remove package
pip install --upgrade pkg Update
pip list Show installed packages
pip freeze > req.txt Save package list
pip install -r req.txt Install from file

🧪 Example: Using Installed Package

Install:

pip install pyjokes

Use in Python:

import pyjokes

print(pyjokes.get_joke())


🛠 Fixing PIP Error: “pip is not recognized”

If pip doesn’t work, install:

Windows:

python -m ensurepip --default-pip

or

python -m pip install --upgrade pip

Mac/Linux:

python3 -m pip install --upgrade pip

🚀 Summary

Feature Supported by PIP
Install packages ✔
Update packages ✔
Remove packages ✔
Manage dependencies ✔
Project requirements ✔

CodeCapsule

Sanjit Sinha — Web Developer | PHP • Laravel • CodeIgniter • MySQL • Bootstrap Founder, CodeCapsule — Student projects & practical coding guides. Email: info@codecapsule.in • Website: CodeCapsule.in

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *