CodingNic

Modules, Packages, and Virtual Environments

pip and Installing Libraries

Modules, Packages, and Virtual Environments 30 min read

pip and Installing Libraries

pip and Installing Libraries

Python has many built-in modules.

But sometimes you need tools created by other developers.

You can install them with pip.

What Is pip?

pip is Python’s package manager.

It helps you:

  • install libraries
  • update libraries
  • remove libraries

A library is extra code you can use in your projects.

Why This Matters

With pip, you can use powerful tools for:

  • web requests
  • data analysis
  • web apps
  • automation
  • games
  • machine learning

Check pip

In the terminal, run:

bash
pip --version

Install a Library

Example: install Requests

bash
pip install requests

Use the Library

python
import requests

Install Specific Version

bash
pip install requests==2.31.0

Upgrade a Library

bash
pip install --upgrade requests

Remove a Library

bash
pip uninstall requests

See Installed Libraries

bash
pip list
  • Flask - web apps
  • Pandas - data tables
  • NumPy - arrays
  • Matplotlib - charts

Common Beginner Errors

pip Not Found

Try:

bash
python -m pip --version

Wrong Python Version

Some computers have multiple Python versions.

Try:

bash
python -m pip install requests

No Internet

Installing packages needs internet access.

Code Along

Install requests.

Then import it in Python.

Mini Challenge

Tasks:

  • Check pip version
  • Install requests
  • Show installed packages

Expected terminal example:

text
requests 2.x.x

Real World Use Case

Developers use pip to install tools for websites, APIs, data science, automation, and testing.

Quiz

  1. What is pip?
  2. What command installs a package?
  3. How do you remove a package?
  4. Why are external libraries useful?

Assignment

Install one Python library, import it, and write one line about what it is used for.

Summary

You learned how to use pip to install, upgrade, list, and remove Python libraries.