← VCE Software Development U4O1

Installing a third-party library with pip

A terminal command that uses pip to download a third-party library (here requests) so a Python program can then import it. Add ==2.31.0 after the name to pick a version.

Understanding Installing a third-party library with pip in VCE Software Development U4O1

What it does: pip install downloads the library once in the terminal, then import makes it usable inside the Python file. pip show displays details about an installed library, including its version number. Third-party libraries are not built into Python. If you import one before installing it, Python raises a ModuleNotFoundError. Use == straight after the library name to choose an exact version. The @ symbol is not used by pip for versions. pip install followed by a library name fetches that library and installs it on the computer. The correct command is pip install requests==2.31.0 to select a specific version.

Common mistakes: The pip command order is wrong. The install keyword comes before the library name: pip install requests. Python code uses the import keyword to load a library after it has been installed. install is a pip command, not Python. It should be: import requests.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 115–124) and word search (Modules 115–171).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which command installs the third-party library requests?
import requests installpip install requests
Matches
import requests pip install requests
↓
The import comes before the install. The library must be installed with pip first, or import fails with ModuleNotFoundError.
Applying
Meanings
Term
pip install requests
Meaning
A terminal command that uses pip to download a third-party library (here requests) so a Python program can then import it. Add ==2.31.0 after the name to pick a version.
Practice
pip install requests==2.31.0
Testing
Gaps
pip requests
Check Answer
Spots
1# In the terminal:
2pip requests install

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Seahorse' badge — Range Rider, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which command installs the third-party library requests?
A. pip install requests ✓
B. import requests install
pip install is a terminal command that downloads the library. import is a Python statement used in your program after installing.
2. True or false: you must run pip install before you can import a third-party library that is not yet on your computer.
A. True ✓
B. False
Third-party libraries are not built into Python. If you import one before installing it, Python raises a ModuleNotFoundError.
3. Where do you type the pip install command?
A. Inside your .py file as a line of Python code
B. In the terminal or command prompt ✓
pip install is a terminal command, not Python code. Typing it in your .py file causes a syntax error.
4. Which order is correct for using the requests library for the first time?
A. pip install requests, then import requests in the program ✓
B. import requests in the program, then pip install requests
Install first so the library exists on your computer, then import it into your program to use it.
5. Which command installs version 2.31.0 of requests?
A. pip install requests@2.31.0
B. pip install requests==2.31.0 ✓
Use == straight after the library name to choose an exact version. The @ symbol is not used by pip for versions.

Match the Pairs

pip install requests → Downloads the third-party requests library so a Python program can import it
pip install requests==2.31.0 → Installs version 2.31.0 of the requests library instead of the latest version
Install a third-party library first, then bring it into a program with import → pip install requests import requests
You can check which version of a library is installed → pip show requests
import requests pip install requests → The import comes before the install. The library must be installed with pip first, or import fails with ModuleNotFoundError.
pip install requests=2.31.0 → A version number needs two equals signs (==). A single = is not valid pip syntax.

Key Term

pip install requests
A terminal command that uses pip to download a third-party library (here requests) so a Python program can then import it. Add ==2.31.0 after the name to pick a version.

Fill in the Blanks

1. pip install requests
Hint: Type the pip subcommand that downloads a library.
2. pip install requests import requests
Hint: Type the library name that the import line uses.
3. pip install requests==2.31.0
Hint: Type the operator that pins an exact version.
4. pip install requests
Hint: Type the name of Python's package installer tool.
5. pip install requests import requests
Hint: Type the keyword that loads the installed library into the program.

Spot the Error

Question 1
A # In the terminal:
B pip requests install
C # In the .py file:
D import requests
Line B — The pip command order is wrong. The install keyword comes before the library name: pip install requests.
Question 2
A # Terminal
B pip install requests
C # Python file
D install requests
E print(requests.__version__)
Line D — Python code uses the import keyword to load a library after it has been installed. install is a pip command, not Python. It should be: import requests.
Question 3
A # Terminal
B # Pick a version
C pip install requests=2.31.0
Line C — A version is chosen with a double equals sign (==) after the library name. A single = is not valid. It should be: pip install requests==2.31.0.
Question 4
A # Terminal
B pip install pyjokes
C # Python file
D import pyjoke
E print(pyjokes.get_joke())
Line D — The library name is spelled wrong. The library installed was pyjokes, so the import must match: import pyjokes.
Question 5
A pip install pillow
B # Python file
C from pillow import Image
Line C — Some libraries are installed under one name but imported under another. pip install pillow is imported as PIL, so the line should be: from PIL import Image.

Student with a class code? Join your class →