"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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -