def safe_import(mod_name, min_version=None):
try:<EOL><INDENT>mod = __import__(mod_name)<EOL><DEDENT>except ImportError:<EOL><INDENT>return False<EOL><DEDENT>if not min_version:<EOL><INDENT>return mod<EOL><DEDENT>else:<EOL><INDENT>import sys<EOL>try:<EOL><INDENT>version = getattr(sys.modules[mod_name], '<STR_LIT>')<EOL><DEDENT>except AttributeError:<EOL><INDENT>version = getattr(sys.modules[mod_name], '<STR_LIT>')<EOL><DEDENT>if version:<EOL><INDENT>from distutils.version import LooseVersion<EOL>if LooseVersion(version) >= LooseVersion(min_version):<EOL><INDENT>return mod<EOL><DEDENT><DEDENT><DEDENT>return False<EOL>
Parameters:
-----------
mod_name : str
    Name of the module to be imported
min_version : str, default None
    Minimum required version of the specified mod_name

Returns:
--------
object
    The imported module if successful, or False