prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  `xonsh.completers.pip` explodes if `pip` is not on PATH
  On my Windows installation, Python is not on PATH (because multiple Python madness), and therefore neither is pip. However, the pip completer [expects pip to be on the path](https://github.com/xonsh/xonsh/blob/master/xonsh/completers/pip.py#L14).
  
  This causes the completer to blow up with a `FileNotFoundError` when it tries to complete.
  
  
  </issue>
  <code>
  [start of xonsh/completers/pip.py]
  1 import re
  2 import subprocess
  3 
  4 import xonsh.lazyasd as xl
  5 
  6 PIP_RE = xl.LazyObject(lambda: re.compile("pip(?:\d|\.)*"),
  7                        globals(), 'PIP_RE')
  8 PIP_LIST_RE = xl.LazyObject(lambda: re.compile("pip(?:\d|\.)* (?:uninstall|show)"),
  9                             globals(), 'PIP_LIST_RE')
  10 
  11 
  12 @xl.lazyobject
  13 def ALL_COMMANDS():
  14     help_text = str(subprocess.check_output(['pip', '--help'],
  15                                             stderr=subprocess.DEVNULL))
  16     commands = re.findall("  (\w+)  ", help_text)
  17     return [c for c in commands if c not in ['completion', 'help']]
  18 
  19 
  20 def complete_pip(prefix, line, begidx, endidx, ctx):
  21     """Completes python's package manager pip"""
  22     line_len = len(line.split())
  23     if (line_len > 3) or (line_len > 2 and line.endswith(' ')) or \
  24                          (not PIP_RE.search(line)):
  25         return
  26     if PIP_LIST_RE.search(line):
  27         items = subprocess.check_output(['pip', 'list'], stderr=subprocess.DEVNULL)
  28         items = items.decode('utf-8').splitlines()
  29         return set(i.split()[0] for i in items)
  30 
  31     if (line_len > 1 and line.endswith(' ')) or line_len > 2:
  32         # "pip show " -> no complete (note space)
  33         return
  34     if prefix not in ALL_COMMANDS:
  35         suggestions = [c for c in ALL_COMMANDS if c.startswith(prefix)]
  36         if suggestions:
  37             return suggestions, len(prefix)
  38     return ALL_COMMANDS, len(prefix)
  39
  [end of xonsh/completers/pip.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/xonsh/completers/pip.py b/xonsh/completers/pip.py
  --- a/xonsh/completers/pip.py
  +++ b/xonsh/completers/pip.py
  @@ -11,8 +11,11 @@
   
   @xl.lazyobject
   def ALL_COMMANDS():
  -    help_text = str(subprocess.check_output(['pip', '--help'],
  -                                            stderr=subprocess.DEVNULL))
  +    try:
  +        help_text = str(subprocess.check_output(['pip', '--help'],
  +                                                stderr=subprocess.DEVNULL))
  +    except FileNotFoundError:
  +        return []
       commands = re.findall("  (\w+)  ", help_text)
       return [c for c in commands if c not in ['completion', 'help']]
   
  @@ -24,7 +27,11 @@
                            (not PIP_RE.search(line)):
           return
       if PIP_LIST_RE.search(line):
  -        items = subprocess.check_output(['pip', 'list'], stderr=subprocess.DEVNULL)
  +        try:
  +            items = subprocess.check_output(['pip', 'list'],
  +                                            stderr=subprocess.DEVNULL)
  +        except FileNotFoundError:
  +            return set()
           items = items.decode('utf-8').splitlines()
           return set(i.split()[0] for i in items)
  
verification_info: {"golden_diff": "diff --git a/xonsh/completers/pip.py b/xonsh/completers/pip.py\n--- a/xonsh/completers/pip.py\n+++ b/xonsh/completers/pip.py\n@@ -11,8 +11,11 @@\n \n @xl.lazyobject\n def ALL_COMMANDS():\n-    help_text = str(subprocess.check_output(['pip', '--help'],\n-                                            stderr=subprocess.DEVNULL))\n+    try:\n+        help_text = str(subprocess.check_output(['pip', '--help'],\n+                                                stderr=subprocess.DEVNULL))\n+    except FileNotFoundError:\n+        return []\n     commands = re.findall(\"  (\\w+)  \", help_text)\n     return [c for c in commands if c not in ['completion', 'help']]\n \n@@ -24,7 +27,11 @@\n                          (not PIP_RE.search(line)):\n         return\n     if PIP_LIST_RE.search(line):\n-        items = subprocess.check_output(['pip', 'list'], stderr=subprocess.DEVNULL)\n+        try:\n+            items = subprocess.check_output(['pip', 'list'],\n+                                            stderr=subprocess.DEVNULL)\n+        except FileNotFoundError:\n+            return set()\n         items = items.decode('utf-8').splitlines()\n         return set(i.split()[0] for i in items)\n", "issue": "`xonsh.completers.pip` explodes if `pip` is not on PATH\nOn my Windows installation, Python is not on PATH (because multiple Python madness), and therefore neither is pip. However, the pip completer [expects pip to be on the path](https://github.com/xonsh/xonsh/blob/master/xonsh/completers/pip.py#L14).\n\nThis causes the completer to blow up with a `FileNotFoundError` when it tries to complete.\n\n", "before_files": [{"content": "import re\nimport subprocess\n\nimport xonsh.lazyasd as xl\n\nPIP_RE = xl.LazyObject(lambda: re.compile(\"pip(?:\\d|\\.)*\"),\n                       globals(), 'PIP_RE')\nPIP_LIST_RE = xl.LazyObject(lambda: re.compile(\"pip(?:\\d|\\.)* (?:uninstall|show)\"),\n                            globals(), 'PIP_LIST_RE')\n\n\n@xl.lazyobject\ndef ALL_COMMANDS():\n    help_text = str(subprocess.check_output(['pip', '--help'],\n                                            stderr=subprocess.DEVNULL))\n    commands = re.findall(\"  (\\w+)  \", help_text)\n    return [c for c in commands if c not in ['completion', 'help']]\n\n\ndef complete_pip(prefix, line, begidx, endidx, ctx):\n    \"\"\"Completes python's package manager pip\"\"\"\n    line_len = len(line.split())\n    if (line_len > 3) or (line_len > 2 and line.endswith(' ')) or \\\n                         (not PIP_RE.search(line)):\n        return\n    if PIP_LIST_RE.search(line):\n        items = subprocess.check_output(['pip', 'list'], stderr=subprocess.DEVNULL)\n        items = items.decode('utf-8').splitlines()\n        return set(i.split()[0] for i in items)\n\n    if (line_len > 1 and line.endswith(' ')) or line_len > 2:\n        # \"pip show \" -> no complete (note space)\n        return\n    if prefix not in ALL_COMMANDS:\n        suggestions = [c for c in ALL_COMMANDS if c.startswith(prefix)]\n        if suggestions:\n            return suggestions, len(prefix)\n    return ALL_COMMANDS, len(prefix)\n", "path": "xonsh/completers/pip.py"}]}