code: def interpreter_versions(self):
          
          if CONF.get('main_interpreter', 'default'):
              from IPython.core import release
              versions = dict(
                  python_version = sys.version.split("\n")[0].strip(),
                  ipython_version = release.version
              )
          else:
              import subprocess
              versions = {}
              pyexec = CONF.get('main_interpreter', 'executable')
              py_cmd = "%s -c 'import sys; print(sys.version.split(\"\\n\")[0])'" % \
                       pyexec
              ipy_cmd = "%s -c 'import IPython.core.release as r; print(r.version)'" \
                        % pyexec
              for cmd in [py_cmd, ipy_cmd]:
                  try:
                      proc = programs.run_shell_command(cmd)
                      output, _err = proc.communicate()
                  except subprocess.CalledProcessError:
                      output = ''
                  output = output.decode().split('\n')[0].strip()
                  if 'IPython' in cmd:
                      versions['ipython_version'] = output
                  else:
                      versions['python_version'] = output
  
          return versions
docs: Python and IPython versions used by clients