Bird
Raised Fist0

You have a folder named utils with a file helper.py inside. You try to import helper using import utils.helper but get ModuleNotFoundError. What is the most likely cause?

medium📝 Debug Q14 of Q15
Python - Modules and Code Organization
You have a folder named utils with a file helper.py inside. You try to import helper using import utils.helper but get ModuleNotFoundError. What is the most likely cause?
AThe <code>helper.py</code> file has syntax errors
BThe <code>helper.py</code> file is empty
CYou need to run Python with administrator rights
DThe <code>utils</code> folder is missing <code>__init__.py</code>
Step-by-Step Solution
Solution:
  1. Step 1: Understand package import requirements

    Python requires an __init__.py file in a folder to treat it as a package for imports like utils.helper.
  2. Step 2: Identify cause of ModuleNotFoundError

    If __init__.py is missing, Python does not recognize utils as a package, causing the error.
  3. Final Answer:

    The utils folder is missing __init__.py -> Option D
  4. Quick Check:

    Missing __init__.py causes import error = D [OK]
Quick Trick: Always add __init__.py to folders for imports [OK]
Common Mistakes:
MISTAKES
  • Blaming syntax errors without checking
  • Thinking admin rights affect imports
  • Assuming empty files cause import failure

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes