35. Module Search Path
When you import a module, Python searches for it in specific locations.
Viewing sys.path
import sys
print(sys.path)
This list shows the directories Python searches for modules.
Importing Custom Modules
If a module is not in the search path, you can:
- Place it in the current directory
- Modify
sys.pathat runtime - Install it as a package
Wrap-Up
Understanding sys.path helps troubleshoot import errors.