ImportError - cannot import other python files

I tried to modularize my code by splitting code into various python files and importing in However, I am encountering ImportError when I did that.

As an example, my skill directory is as follows:

– /dialog
– /vocab
– …

Where inside I defined a function called fib.

When I add the line import test in the skill loaded normally. But when I tried to call test.fib it raises an import error, saying it cannot find fib. Similarly, when I tried from test import fib, I also get an import error, saying:

ImportError: cannot import name ‘fib’ from ‘test’

Could someone help me with this? I can’t figure out why this doesn’t work. Thanks in advance!

I have seem to found the solution. The importing syntax is a little different. We must use

from . import (test)

to import the module. If the module file is located inside a subfolder, say, lib. Then we must import it by

from .lib import (test)