docs: def _install(self, name, autoinstall):
          '''Check existence of Python module and install it using command
          pip install if necessary.'''
          import importlib
          import pkg_resources
          spam_spec = importlib.util.find_spec(name)
          reinstall = False
          if spam_spec is not None:
              if self._version:
                  mod = importlib.__import__(name)
                  if hasattr(mod, '__version__'):
                      ver = mod.__version__
                  else:
                      try:
                          ver = pkg_resources.get_distribution(name).version
                      except Exception as e:
                          env.logger.debug(
                              f'Failed to get version of {name}: {e}')
                  env.logger.debug(
                      f'Comparing exiting version {ver} against requested version {self._version}'
                  )
                  if self._version.startswith(
                          '==') and pkg_resources.parse_version(
                              ver) == pkg_resources.parse_version(
                                  self._version[2:]):
                      pass
                  elif self._version.startswith(
                          '<=') and pkg_resources.parse_version(
                              ver) <= pkg_resources.parse_version(
                                  self._version[2:]):
                      pass
                  elif self._version.startswith(
                          '<') and not self._version.startswith(
                              '<=') and pkg_resources.parse_version(
                                  ver) < pkg_resources.parse_version(
                                      self._version[1:]):
                      pass
                  elif self._version.startswith(
                          '>=') and pkg_resources.parse_version(
                              ver) >= pkg_resources.parse_version(
                                  self._version[2:]):
                      pass
                  # the case of >
                  elif self._version.startswith(
                          '>') and not self._version.startswith(
                              '>=') and pkg_resources.parse_version(
                                  ver) > pkg_resources.parse_version(
                                      self._version[1:]):
                      pass
                  elif self._version.startswith(
                          '!=') and pkg_resources.parse_version(
                              ver) != pkg_resources.parse_version(
                                  self._version[2:]):
                      pass
                  elif self._version[0] not in (
                          '=', '>', '<', '!') and pkg_resources.parse_version(
                              ver) == pkg_resources.parse_version(self._version):
                      pass
                  else:
                      env.logger.warning(
                          f'Version {ver} of installed {name} does not match specified version {self._version}.'
                      )
                      reinstall = True
          if spam_spec and not reinstall:
              return True
          if not autoinstall:
              return False
          # try to install it?
          import subprocess
          cmd = ['pip', 'install'] + ([] if self._version else ['-U']) + [
              self._module + (self._version if self._version else '')
              if self._autoinstall is True else self._autoinstall
          ]
          env.logger.info(
              f'Installing python module {name} with command {" ".join(cmd)}')
          ret = subprocess.call(cmd)
          if reinstall:
              import sys
              importlib.reload(sys.modules[name])
          # try to check version
          return ret == 0 and self._install(name, False)