You can import a file from outside the current directory by using the sys.path variable in Python. Of the sys module. By using this variable, you can see all the directories the module contains. Therefore, you must append the mod.py in sys rather than mod.py in main.py.