There's no direct way to modify namespaces in lxml. Instead you'd have to clone the tree, somethinf like
Code:
from calibre.ebooks.oeb.parse_utils import clone_element
nsmap = root.nsmap.copy()
nsmap['my namespace prefix'] = 'my namespace'
newroot = clone_element(root, nsmap, in_context=False)
container.replace(name, newroot)