I tried to modularize my code by splitting code into various python files and importing in __init__.py
. However, I am encountering ImportError
when I did that.
As an example, my skill directory is as follows:
/my-mycroft-skill
– /dialog
– /vocab
– __init__.py
– test.py
– …
Where inside test.py
I defined a function called fib
.
When I add the line import test
in __init__.py
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!