for k in sys.modules:
    if re.match('foo(\\.|$)', k):
        newk = k.replace('foo', 'foo2', 1)
sys.modules[newk] = sys.modules[k]
del sys.modules[k]
Is it possible to use two Python packages with the same name?