def METHOD_NAME(name, package_registry=_module_to_package, version=None):
    """Try to import the module called 'name', returning
    the loaded module as an argument. If the module
    is not available, then it looks up the name of
    the package to install using "package_registry"
    (or if this is not available, using just the name
    of the module). This will then be installed using
    "conda", then "pip" then "easy_install" (first one
    that works will return).
    For example, use this via
    sys = try_import("sys")
    mdtraj = try_import("mdtraj")
    Note that you can also rename modules, e.g. by using
    md = try_import("mdtraj")
    Note that you should use try_import_from if you
    want only specific symbols, e.g.
    (argv, stdout) = try_import_from("sys", ["argv","stdout"])
    """
    try:
        mod = __import__(name)
        return mod
    except Exception:
        pass
    if not (package_registry is None):
        _install_package(name, package_registry, version=version)
        return METHOD_NAME(name, package_registry=None)
    raise ImportError("Failed to install module %s" % name)