Python PIP


PIP is the package installer for Python. It allows you to install and manage additional libraries and dependencies that are not part of the Python standard library.


🔹 What is PIP?

PIP stands for Pip Installs Packages. It is used to install Python packages from PyPI (Python Package Index).


🔹 Check if PIP is Installed

You can check if PIP is already installed by running this command in your terminal or command prompt:

pip --version

✅ Output example:
pip 24.0 from ... (python 3.x)


🔹 Install a Package

Use the following command to install any Python package:

pip install package-name

Example:

pip install requests

🔹 Use Installed Package

Once installed, you can import and use it in your Python code:

import requests

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

🔹 List All Installed Packages

pip list

✅ This shows all packages currently installed in your Python environment.


🔹 Show Package Info

pip show package-name

Example:

pip show numpy

🔹 Uninstall a Package

pip uninstall package-name

Example:

pip uninstall flask

🔹 Upgrade a Package

pip install --upgrade package-name

Example:

pip install --upgrade pandas

🔹 Requirements File

You can install multiple packages from a file named requirements.txt:

pip install -r requirements.txt

✅ This is commonly used in projects to install all dependencies at once.


Practice Questions

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.


Python PIP Quiz

Q1: What does PIP stand for?

A. Python Import Package
B. Pip Installs Packages
C. Program Install Processor
D. Python Input Processor

Q2: Which command installs a new package using pip?

A. pip add
B. pip new
C. pip install
D. pip use

Q3: What does pip uninstall flask do?

A. Updates Flask
B. Installs Flask
C. Removes Flask package
D. Lists Flask modules

Q4: How do you list all installed pip packages?

A. pip packages
B. pip all
C. pip list
D. pip get

Q5: What does pip show numpy do?

A. Displays numpy array
B. Imports numpy
C. Shows details of the numpy package
D. Opens numpy website

Q6: Where does pip install packages from?

A. GitHub
B. Local folder
C. Python Package Index (PyPI)
D. Anaconda

Q7: Which file helps install multiple packages at once?

A. packages.txt
B. pip.txt
C. requirements.txt
D. modules.txt

Q8: Which command upgrades an installed package?

A. pip install new
B. pip refresh
C. pip upgrade
D. pip install --upgrade

Q9: Can you use pip for Python standard libraries like math?

A. Yes
B. No
C. Only with admin access
D. Only in Python 2

Q10: Which of the following is a correct pip command?

A. pip remove pandas
B. pip install pandas
C. pip update pandas
D. pip open pandas

Go Back Top