How to dynamically import python module A in module B which uses module B

I'm currently developing the service which should dynamically import python code files (modules) and call function in each of these modules AttributeError. The problem, if I understood the error correctly, lies in the fact that I'm importing the module Launcher (module which initiated importing of the module SomeModuleToImport) in the module SomeModuleToImport.

How can I resolve it? Also I will need to reimport module each time I need it because the code in SomeModuleToImport can be changed during runtime.

Python version 3.6.1.

File structure:


import importlib

script = importlib.import_module("SomeModuleToImport")

def writeMsg(txt):

import Launcher

def handle(user, req):


   Traceback (most recent call last):
  File "/Users/lexmint/Dropbox/Archive/Development/Breeze/", line 3, in <module>
    script = importlib.import_module("unban")
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "/Users/lexmint/Dropbox/Archive/Development/Breeze/", line 1, in <module>
    import Launcher
  File "/Users/lexmint/Dropbox/Archive/Development/Breeze/", line 4, in <module>
AttributeError: module 'SomeModuleToImport' has no attribute 'handle'