Python Imports and sys.path
PCAP objective 1.1 is import and use modules and packages, and it is the first subject in either syllabus that PCEP does not mention. There are five import forms and each binds different names - which is the whole examinable content, because `from math import pi` gives you `pi` and specifically does not give you `math`. Beyond that: the two import failures raise different exceptions, and a module body runs exactly once no matter how many times you import it.
Modules and Packages Guide 4 of 25 Intermediate
- Python3.14.4
- OSUbuntu 26.04 LTS
- pip25.1.1
- TimeAbout 16 min
- Reviewed23 August 2026
Written against the versions above. `ModuleNotFoundError` was added in Python 3.6 as a subclass of `ImportError`; older material says `ImportError` for a missing module and is not wrong, just less specific. Everything else here is unchanged since Python 3.0.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| RUNNER01 | 192.168.0.27 | Ubuntu 26.04 LTS | Python 3.14.4 - the only machine this path needs | 2 Core | 4 GB | 50 GB |
Before you start
- guide 4 - the
__pycache__behaviour comes from there. - guide 23 -
ModuleNotFoundErroris anImportError.
-
The five import forms
-
What from ... import specifically does not give you
-
The two ways an import fails
-
Where Python looks
-
Not every module is a file
-
What a module offers
-
A module body runs once, however often you import it
-
__name__ tells a file how it was started
-
What the exam does with this objective