import thepackage
sys.modules['thepackage'].submodule = myreplacement
sys.modules['thepackage.submodule'] = myreplacement
Python: How can I override one module in a package with a modified version that lives outside the package?