Find the versions of the given named modules, printing the discovered
    versions to stdout and errors discovering versions to stderr.

def find_version(*args):
    """Find the versions of the given named modules, printing the discovered
    versions to stdout and errors discovering versions to stderr."""
    if len(args) == 1:
        ver_template = "%(version)s"
        error_template = "Distribution/module '%(mod)s' not found (%(error)s)"
    else:
        ver_template = "%(mod)s: %(version)s"
        error_template = "%(mod)s: not found (%(error)s)"

    import pkg_resources
    for modulename in args:
        try:

            try:
                dist = pkg_resources.get_distribution(modulename)
            except pkg_resources.DistributionNotFound:

                mod = identify_module(modulename)  # raises ModuleNotFound
                if not hasattr(mod, '__version__'):
                    raise ModuleNotFound('module has no __version__')
                version = mod.__version__

            else:
                version = dist.version

        except ModuleNotFound:
            exc = sys.exc_info()[1]
            sys.stderr.write(error_template % {
                'mod': modulename,
                'error': str(exc),
            })
            sys.stderr.write('\n')
        else:
            print(ver_template % {
                'mod': modulename,
                'version': version,
            })