-
Hajipur, Bihar, 844101
PIP is the package manager for Python. It helps you install, update and remove external libraries that are not included in the standard Python installation. Almost every Python project depends on packages, so learning PIP is important if you plan to work with frameworks, automation tools, data science libraries or web development.
In this tutorial, you will learn what PIP is, how to check if it is installed, how to use it to install and manage packages, how to uninstall packages, how to see which packages are installed and how to work with requirements files. All examples are simple and practical so you can start using PIP confidently.
PIP stands for "Package Installer for Python." It lets you download and install Python packages from the Python Package Index (PyPI). PyPI is an online repository of thousands of ready-to-use libraries created by developers worldwide.
Some popular packages include:
requests for handling HTTP requests
numpy for mathematical calculations
pandas for data analysis
flask and django for web applications
opencv-python for image processing
Instead of writing everything from scratch, you can use these libraries to speed up your work.
Most Python versions include PIP automatically. You can check it by running this command in your terminal or command prompt:
pip --version
If PIP is installed, you will see something like:
pip 24.0 from /usr/local/lib/python3.12/site-packages
If you see an error, it means PIP is not installed or not added to the system path.
Use the pip install command to install any package.
Example:
pip install requests
This will download the requests library and install it on your system.
You can also install a specific version:
pip install requests==2.31.0
This is useful when your project requires a fixed version.
To update an installed package to its latest version, use:
pip install --upgrade requests
This checks PyPI for new releases and updates the package automatically.
If you no longer need a library, remove it using:
pip uninstall requests
You will be asked to confirm the uninstall process.
You can install more than one package in a single command:
pip install numpy pandas matplotlib
This saves time when setting up new projects.
Use this command to list all installed packages:
pip list
It shows package names and versions.
Example output:
numpy 1.26.0
pandas 2.1.1
requests 2.31.0
To find outdated packages:
pip list --outdated
This is helpful when you want to keep your environment up to date.
If you want to know more about a package, use:
pip show requests
This gives you information like version, summary, author and installation location.
A requirements.txt file is commonly used in projects to store package names and their versions.
Example requirements.txt:
numpy==1.26.0
pandas==2.1.1
requests==2.31.0
To install everything inside the file:
pip install -r requirements.txt
This is very useful when sharing a project with someone else or deploying a project on a server.
You can generate a requirements.txt file using:
pip freeze > requirements.txt
This command saves all your installed packages with exact versions.
By default, PIP installs packages globally. You can also install packages only for a project by using a virtual environment.
Example:
python -m venv myenv
source myenv/bin/activate # Mac/Linux
myenv\Scripts\activate # Windows
pip install flask
This keeps your project dependencies isolated and avoids version conflicts.
Some packages are stored on GitHub or a custom server. You can install them like this:
pip install https://github.com/user/repository/archive/main.zip
You can even install from a GitHub repo:
pip install git+https://github.com/psf/requests
Developers use editable mode when working on packages locally:
pip install -e .
This installs the package in a way that reflects live changes.
Try adding --user:
pip install --user package_name
Use:
python -m pip install package_name
If PIP is outdated:
pip install --upgrade pip
Install Django
pip install django
Install the latest version of NumPy
pip install --upgrade numpy
Remove Pandas
pip uninstall pandas
Check a package version
pip show flask
List outdated packages
pip list --outdated
Install packages for a project
pip install -r requirements.txt
Generate a requirements file
pip freeze > requirements.txt
Install a package from GitHub
pip install git+https://github.com/pallets/flask
Install specific version
pip install matplotlib==3.7.1
Reinstall a package
pip install --force-reinstall requests
PIP makes it easy to install and manage Python packages. You learned how to install, upgrade and remove packages, how to list installed packages, how to use requirements files and how to install packages from URLs or GitHub. PIP is a key tool for every Python developer, and understanding how to use it gives you control over your project’s dependencies.
Q1. Write a terminal command to check your current pip version.
Q2. Write a terminal command to install the pandas package using pip.
Q3. Write a Python program to import and use the math package (standard library).
Q4. Write a terminal command to uninstall the flask package from your system.
Q5. Write a terminal command to list all installed packages and check if requests is installed.
Q6. Write a terminal command to show full details of the numpy package using pip show.
Q7. Write a terminal command to upgrade the scikit-learn package to the latest version.
Q8. Write a terminal command to install packages from a requirements.txt file.
Q9. Write a terminal command to try installing a non-existent package and observe the error.
Q10. Write a terminal command to reinstall a broken package using pip.