What is a module search path in Python?
Experience Level: Junior
Tags: Python
Answer
When the Python interpreter executed the import statement, it tries to search for the module in search path.
In the example below, the interpreter sees a module basic_math is to be imported, it searches for the file name basic_math.py in the search path.
It looks into the following folders:
- The folder from which the input script was run (or the current folder if the interpreted is executed interactively)
- The list of folders from PYTHONPATH environment variable (if it is defined)
- An installation-dependent list of folders configured at the time Python is installed
Example:
File main.py
import basic_math
File basic_math.py
def add(x, y):
return x+y
Related Python job interview questions
What is the print() function good for in Python?
Python JuniorHow do you obtain a value of search path in Python?
Python JuniorWhat is the import statement good for in Python?
Python Junior
Chat
Oh, the operator is not available. Leave us your comments. We will answer all your questions as soon as possible.
Anonymous
Καλησπέρα.
Καλησπέρα.
Anonymous
the infinteis -3/15 so 1triition / infinet
the infinteis -3/15 so 1triition / infinet
Anonymous
e
e
Anonymous
<a href="https://inspirum.pl "
<a href="https://inspirum.pl "
Anonymous
[url]https://inspirum.pl[/url]
[url]https://inspirum.pl[/url]
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e