'AWS Glue - How to import extra.py files in a subfolder/directory?

My directory structure for the Glue extra.py/library files looks like this:

├── script1.py
├── folder1
│   └── script2.py

I can import script1.py like normal:

from script1 import foo

But when I try for script2.py:

from folder1.script2 import foo

it doesn't work and it will trigger an exception saying Module folder1 not found.

Any help on this?



Solution 1:[1]

You should put a "__init__.py" file in the folder1.

This is useful for understanding about "__init__.py".

What is __init__.py for?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 e-zuka