We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN 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.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `xonsh/completers/pip.py`
Content:
```
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 FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

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)

{"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"}], "after_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    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\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        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\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"}]}