This question is related to this one. After going through the python's module documentation here, I'm unable to import a submodule into a script file included in a module that includes the respective submodule.
My setup is as follows:
where the source files contents are:
app.py
import sys
def app():
print("Nice, this file has a __main__ entry point. It doesn't handle arguments though")
if __name__ == '__main__':
# python app.py 2>&1 | less +F
app()
sys.exit(0)
launcher.py
import sys
from multiprocessing import Process
import test_module.test_submodule.app
p1 = Process(target=app, args=('no args yet',))
print("Launcher starting ...")
p1.start()
sys.exit(0)
(the init files are blank).
My configuration for pycharm is:
Why can't the app method be called in the launcher script?
The following error is thrown when running the script:
Connected to pydev debugger (build 145.260)
Traceback (most recent call last):
File "/home/Pycharm/pycharm-community-2016.1/helpers/pydev/pydevd.py", line 1530, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "/home/Pycharm/pycharm-community-2016.1/helpers/pydev/pydevd.py", line 937, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/home/Pycharm/pycharm-community-2016.1/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "launcher.py", line 6, in <module>
p1 = Process(target=test_module.test_submodule.app, args=('no args yet',))
AttributeError: 'module' object has no attribute 'test_submodule'