🎓 A1Learner
🔍
0 of 116 lessons completed

Python PIP

pip is a tool that fetches and installs Python packages. Packages for pip come from PyPI, the public store for Python packages.

Check pip

You type pip commands in a terminal. You do not type them in a .py file.

pip --version

Install a package

This command asks pip to fetch one package. The package here is called requests.

pip install requests

List and remove

List shows what you have. Uninstall takes one package away again.

pip list
pip uninstall requests

A tool that comes with Python

Some tools already live inside Python. The math module is one of them, so it needs no install.

import math
print(math.sqrt(25))

Example

pip install requests

Key points

  • PyPI: the public store where Python packages live
  • Package: ready-made code that you can add to your own project
  • pip adds ready packages from PyPI to a project.
  • Use pip --version to check that pip is ready
  • Use pip install to add a package to your Python
  • Use pip list to see the packages you have
  • Use pip uninstall to remove a package

In this example, you read a terminal transcript. It is not a program to run. The command pip install requests asks pip to fetch the requests package from PyPI. The first line of the output shows pip finding the package. The last line shows that the install finished. Nothing was installed for this lesson, because course examples use only the standard library.

Note

In this course, pip lessons show transcripts to read.

You do not run pip here, and no package is installed.

Try it Yourself

Edit the code, then press Run.

Running is simulated · Python Playground

Exercise

What does pip install requests do?