pip is the package manager for Python.
It is used to install, upgrade, and manage external (third-party) libraries.
Pip helps you:
- Install new packages
- Upgrade packages
- Remove packages
- Manage project dependencies
WHAT IS PIP?
Pip stands for “Pip Installs Packages”.
It downloads packages from the Python Package Index (PyPI).
Most Python installations already include pip.
CHECK PIP VERSION
Open Command Prompt or Terminal:
pip --version
Or:
python -m pip --version
INSTALL A PACKAGE
pip install package_name
Example:
pip install requests
This installs the requests library.
IMPORT INSTALLED PACKAGE
After installation, use it in Python:
import requestsresponse = requests.get("https://example.com")
print(response.status_code)
INSTALL SPECIFIC VERSION
pip install package_name==version
Example:
pip install numpy==1.24.0
UPGRADE A PACKAGE
pip install --upgrade package_name
Example:
pip install --upgrade requests
UNINSTALL A PACKAGE
pip uninstall package_name
Example:
pip uninstall numpy
LIST INSTALLED PACKAGES
pip list
Shows all installed libraries.
SHOW PACKAGE DETAILS
pip show package_name
Example:
pip show requests
FREEZE REQUIREMENTS (FOR PROJECTS)
pip freeze
Used to create a requirements file:
pip freeze > requirements.txt
To install from requirements file:
pip install -r requirements.txt
This is very important for professional projects.
VIRTUAL ENVIRONMENT (RECOMMENDED)
For project isolation:
python -m venv myenv
Activate environment:
Windows:
myenv\Scripts\activate
Mac/Linux:
source myenv/bin/activate
Then install packages inside the virtual environment.
WHY USE PIP?
• Access thousands of Python libraries
• Manage project dependencies
• Keep projects organized
• Essential for real-world development
KEY TAKEAWAYS
• pip install → Install package
• pip uninstall → Remove package
• pip list → View installed packages
• pip freeze → Save dependencies
• Use virtual environments for professional projects
Working with pip is essential for building modern and scalable Python applications.