easyMultiple ChoiceObjective-mapped
XK0-006 Practice Question: A developer writes a Python script that uses the…
A developer writes a Python script that uses the `requests` library to fetch data from an API. The script works on the developer's workstation but fails on the server with an import error. What is the most likely cause?
⚠ Common exam trap
CompTIA often tests the distinction between runtime errors (e.g., network issues, bad endpoints) and import-time errors (e.g., missing modules), trapping candidates who confuse an ImportError with a connectivity or syntax problem.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
The `requests` module is not installed on the server
The `requests` library is a third-party Python package that must be installed separately via `pip` or a package manager. The script works on the developer's workstation because `requests` is present there, but fails on the server with an import error, indicating the module is missing from the server's Python environment. This is the most likely cause because an import error specifically points to a missing module, not to network or syntax issues.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
The `requests` module is not installed on the server
Why this is correct
The `requests` module is not part of the standard library and must be installed via pip.
- ✗
The script uses an incorrect API endpoint
Why it's wrong here
An incorrect endpoint would cause an HTTP error, not an import error.
- ✗
The server lacks internet connectivity
Why it's wrong here
Lack of internet might cause a connection error, not an import error.
- ✗
The script has a syntax error in the import statement
Why it's wrong here
A syntax error would prevent the script from running at all, but the error message would indicate a syntax error.
Go deeper
Related to this question
About these practice questions
This XK0-006 question is part of Courseiva's 979-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This XK0-006 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the XK0-006 exam.