Why does this import code work in Visual Studio Code but not IDLE?

Viewed 40

File Structure

Main Folder

Program.py

Module_Folder
     MODULE_1.py
     MODULE_2.py
     MODULE_3.py

In "Program.py" I am using the following line to import MODULE_1 into Program.py: "from Module_Folder import MODULE_1 as MODULE_1" This works in visual studio code but not in IDLE. Could someone advise me on what to change for this to work in IDLE?

1 Answers

You should probably add an __init__.py file to your Module_Folder, so Python would know it's a package. You cannot simply import files from folders, if they don't have __init__.py

Related