"no module named..." when running this python code -
i have no idea causes error, simplest get, yet gives me hint question not meet quality standards must post longer intro.
#=== # my_script.py import mymodule #=== # mymodule\__init__.py import sys my_def import * class mymodule: def __init__(self): pass #=== # mymodule\my_def.py def my_def(): pass traceback (most recent call last): file "my_script.py", line 1, in <module> import mymodule file "d:\test\mymodule\__init__.py", line 2, in <module> my_def import * importerror: no module named 'my_def'
in __init__.py
, add .
before my_def
. .
means should looking file in same folder script itself, rather relative my_script.py
.
from .my_def import *
Comments
Post a Comment