pythonpath directories (if set standard library directories the contents of any pth files (if present the site-packages home of third-party extensions ultimatelythe concatenation of these four components becomes sys patha mutable list of directory name strings that 'll expand upon later in this section the first and third elements of the search path are defined automatically because python searches the concatenation of these components from first to lastthoughthe second and fourth elements can be used to extend the path to include your own source code directories here is how python uses each of these path componentshome directory (automaticpython first looks for the imported file in the home directory the meaning of this entry depends on how you are running the code when you're running programthis entry is the directory containing your program' top-level script file when you're working interactivelythis entry is the directory in which you are working ( the current working directorybecause this directory is always searched firstif program is located entirely in single directoryall of its imports will work automatically with no path configuration required on the other handbecause this directory is searched firstits files will also override modules of the same name in directories elsewhere on the pathbe careful not to accidentally hide library modules this way if you need them in your programor use package tools we'll meet later that can partially sidestep this issue pythonpath directories (configurablenextpython searches all directories listed in your pythonpath environment variable settingfrom left to right (assuming you have set this at allit' not preset for youin briefpythonpath is simply list of user-defined and platform-specific names of directories that contain python code files you can add all the directories from which you wish to be able to importand python will extend the module search path to include all the directories your pythonpath lists because python searches the home directory firstthis setting is only important when importing files across directory boundaries--that isif you need to import file that is stored in different directory from the file that imports it you'll probably want to set your pythonpath variable once you start writing substantial programsbut when you're first starting outas long as you save all your module files in the directory in which you're working ( the home directorylike the :\code used in this bookyour imports will work without you needing to worry about this setting at all the module search path