from datetime import datetime, timezone


def _get_version_info():
    """
    Return a dictionary of the installed version numbers for photutils
    and its dependencies.

    Returns
    -------
    result : dict
        A dictionary containing the version numbers for photutils and
        its dependencies.
    """
    versions = {}
    packages = ('photutils', 'astropy', 'numpy', 'scipy', 'skimage')
    for package in packages:
        try:
            pkg = __import__(package)
            version = pkg.__version__
        except ImportError:
            version = None

        versions[package] = version

    return versions


def _get_date(utc=False):
    """
    Return a string of the current date/time.

    Parameters
    ----------
    utz : bool, optional
        Whether to use the UTZ timezone instead of the local timezone.

    Returns
    -------
    result : str
        The current date/time.
    """
    if not utc:
        now = datetime.now().astimezone()
    else:
        now = datetime.now(timezone.utc)

    return now.strftime('%Y-%m-%d %H:%M:%S %Z')


def _get_meta(utc=False):
    """
    Return a metadata dictionary with the package versions and current
    date/time.
    """
    return {'date': _get_date(utc=utc),
            'version': _get_version_info()}

from datetime import datetime, timezone
import sys


def _get_version_info():
    """
    Return a dictionary of the installed version numbers for photutils
    and its dependencies.

    Returns
    -------
    result : dict
        A dictionary containing the version numbers for photutils and
        its dependencies.
    """
    versions = {'Python': sys.version.split()[0]}

    packages = ('photutils', 'astropy', 'numpy', 'scipy', 'skimage',
                'sklearn', 'matplotlib', 'gwcs', 'bottleneck')
    for package in packages:
        try:
            pkg = __import__(package)
            version = pkg.__version__
        except ImportError:
            version = None

        versions[package] = version

    return versions


def _get_date(utc=False):
    """
    Return a string of the current date/time.

    Parameters
    ----------
    utz : bool, optional
        Whether to use the UTZ timezone instead of the local timezone.

    Returns
    -------
    result : str
        The current date/time.
    """
    if not utc:
        now = datetime.now().astimezone()
    else:
        now = datetime.now(timezone.utc)

    return now.strftime('%Y-%m-%d %H:%M:%S %Z')


def _get_meta(utc=False):
    """
    Return a metadata dictionary with the package versions and current
    date/time.
    """
    return {'date': _get_date(utc=utc),
            'version': _get_version_info()}

Add all optional dependencies to version info dict
Add all optional dependencies to version info dict

  from datetime import datetime, timezone
+ import sys
  
  
  def _get_version_info():
      """
      Return a dictionary of the installed version numbers for photutils
      and its dependencies.
  
      Returns
      -------
      result : dict
          A dictionary containing the version numbers for photutils and
          its dependencies.
      """
-     versions = {}
+     versions = {'Python': sys.version.split()[0]}
+ 
-     packages = ('photutils', 'astropy', 'numpy', 'scipy', 'skimage')
+     packages = ('photutils', 'astropy', 'numpy', 'scipy', 'skimage',
+                 'sklearn', 'matplotlib', 'gwcs', 'bottleneck')
      for package in packages:
          try:
              pkg = __import__(package)
              version = pkg.__version__
          except ImportError:
              version = None
  
          versions[package] = version
  
      return versions
  
  
  def _get_date(utc=False):
      """
      Return a string of the current date/time.
  
      Parameters
      ----------
      utz : bool, optional
          Whether to use the UTZ timezone instead of the local timezone.
  
      Returns
      -------
      result : str
          The current date/time.
      """
      if not utc:
          now = datetime.now().astimezone()
      else:
          now = datetime.now(timezone.utc)
  
      return now.strftime('%Y-%m-%d %H:%M:%S %Z')
  
  
  def _get_meta(utc=False):
      """
      Return a metadata dictionary with the package versions and current
      date/time.
      """
      return {'date': _get_date(utc=utc),
              'version': _get_version_info()}
  
Add all optional dependencies to version info dict
## Code Before:
from datetime import datetime, timezone


def _get_version_info():
    """
    Return a dictionary of the installed version numbers for photutils
    and its dependencies.

    Returns
    -------
    result : dict
        A dictionary containing the version numbers for photutils and
        its dependencies.
    """
    versions = {}
    packages = ('photutils', 'astropy', 'numpy', 'scipy', 'skimage')
    for package in packages:
        try:
            pkg = __import__(package)
            version = pkg.__version__
        except ImportError:
            version = None

        versions[package] = version

    return versions


def _get_date(utc=False):
    """
    Return a string of the current date/time.

    Parameters
    ----------
    utz : bool, optional
        Whether to use the UTZ timezone instead of the local timezone.

    Returns
    -------
    result : str
        The current date/time.
    """
    if not utc:
        now = datetime.now().astimezone()
    else:
        now = datetime.now(timezone.utc)

    return now.strftime('%Y-%m-%d %H:%M:%S %Z')


def _get_meta(utc=False):
    """
    Return a metadata dictionary with the package versions and current
    date/time.
    """
    return {'date': _get_date(utc=utc),
            'version': _get_version_info()}

## Instruction:
Add all optional dependencies to version info dict
## Code After:
from datetime import datetime, timezone
import sys


def _get_version_info():
    """
    Return a dictionary of the installed version numbers for photutils
    and its dependencies.

    Returns
    -------
    result : dict
        A dictionary containing the version numbers for photutils and
        its dependencies.
    """
    versions = {'Python': sys.version.split()[0]}

    packages = ('photutils', 'astropy', 'numpy', 'scipy', 'skimage',
                'sklearn', 'matplotlib', 'gwcs', 'bottleneck')
    for package in packages:
        try:
            pkg = __import__(package)
            version = pkg.__version__
        except ImportError:
            version = None

        versions[package] = version

    return versions


def _get_date(utc=False):
    """
    Return a string of the current date/time.

    Parameters
    ----------
    utz : bool, optional
        Whether to use the UTZ timezone instead of the local timezone.

    Returns
    -------
    result : str
        The current date/time.
    """
    if not utc:
        now = datetime.now().astimezone()
    else:
        now = datetime.now(timezone.utc)

    return now.strftime('%Y-%m-%d %H:%M:%S %Z')


def _get_meta(utc=False):
    """
    Return a metadata dictionary with the package versions and current
    date/time.
    """
    return {'date': _get_date(utc=utc),
            'version': _get_version_info()}
