modnames = set([modname for importer, modname, ispkg in pkgutil.
    walk_packages(path=[os.path.dirname(encodings.__file__)], prefix='')])
aliases = set(encodings.aliases.aliases.values())
print(modnames - aliases)
How can I programmatically find the list of codecs known to Python?