I have the following folder structure:
C:
└── dev
└── my_scripts
├── __init__.py
└── my_utils.py
The file my_utils.py includes some function f.
The following code works:
import sys
sys.path.append('C:\dev')
from my_scripts import my_utils
my_utils.f()
However the following does not work:
import sys
sys.path.append('C:\dev')
import my_scripts
my_scripts.my_utils.f()
> AttributeError: module 'my_scripts' has no attribute 'my_utils'
Why am I getting this error?
__init__.pyfile (in this casefrom .my_utils import *would work) in order to be able to do what you want.