Search code examples
pythonbatch-filepython-module

Python Module error even though init file kept


enter image description here

I am not sure what to do here.

The below image shows the heirarchy.

enter image description here

I tried init file in the code.

Kept main.py (not using it) in the parent folder


Solution

  • The problem is that "import Data_Upload" looks for that file in the current directory. In your example, the current directory is E:\Traffic_Dip_4G, and that's not where the module is located. You need to add the parent of your top-level directory to the Python path (sys.path) so it can be found.

    Something like this, BEFORE you do any other imports:

    import os
    import sys
    sys.path.append(os.path.abspath(os.path.dirname(__file__)+'/../..'))