code: def package_check(
      pkg_name,
      version=None,
      app=None,
      checker=LooseVersion,
      exc_failed_import=ImportError,
      exc_failed_check=RuntimeError,
  ):
      """Check that the minimal version of the required package is installed.
  
      Parameters
      ----------
      pkg_name : string
          Name of the required package.
      version : string, optional
          Minimal version number for required package.
      app : string, optional
          Application that is performing the check.  For instance, the
          name of the tutorial being executed that depends on specific
          packages.  Default is *Nipype*.
      checker : object, optional
          The class that will perform the version checking.  Default is
          nipype.external.version.LooseVersion.
      exc_failed_import : Exception, optional
          Class of the exception to be thrown if import failed.
      exc_failed_check : Exception, optional
          Class of the exception to be thrown if version check failed.
  
      Examples
      --------
      package_check('numpy', '1.3')
      package_check('scipy', '0.7', 'tutorial1')
  
      """
  
      if app:
          msg = f"{app} requires {pkg_name}"
      else:
          msg = "Nipype requires %s" % pkg_name
      if version:
          msg += f" with version >= {version}"
      try:
          mod = __import__(pkg_name)
      except ImportError as e:
          raise exc_failed_import(msg) from e
      if not version:
          return
      try:
          have_version = mod.__version__
      except AttributeError as e:
          raise exc_failed_check(
              "Cannot find version for %s" % pkg_name
          ) from e
      if checker(have_version) < checker(version):
          raise exc_failed_check(msg)
  
file_path: nipype/nipype/utils/misc.py
imports: import os
  import sys
  import re
  from collections.abc import Iterator
  from warnings import warn
  from looseversion import LooseVersion
  import numpy
  import textwrap
label_desc: Use image node_id 6 for calling a global function with example usage: package_check(pkg_name, version, app, checker, exc_failed_import, exc_failed_check) without return types