We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
kinto init should install postgresql dependencies


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `kinto/__main__.py`
Content:
```
1 from __future__ import print_function
2 import argparse
3 import os
4 import sys
5 from six.moves import input
6 from cliquet.scripts import cliquet
7 from pyramid.scripts import pserve
8 from pyramid.paster import bootstrap
9 
10 from kinto.config import init
11 
12 CONFIG_FILE = 'config/kinto.ini'
13 
14 
15 def main(args=None):
16     """The main routine."""
17     if args is None:
18         args = sys.argv[1:]
19 
20     parser = argparse.ArgumentParser(description="Kinto commands")
21     parser.add_argument('--ini',
22                         help='Application configuration file',
23                         dest='ini_file',
24                         required=False,
25                         default=CONFIG_FILE)
26     parser.add_argument('--backend',
27                         help='Specify backend',
28                         dest='backend',
29                         required=False,
30                         default=None)
31 
32     subparsers = parser.add_subparsers(title='subcommands',
33                                        description='valid subcommands',
34                                        help='init/start/migrate')
35 
36     parser_init = subparsers.add_parser('init')
37     parser_init.set_defaults(which='init')
38 
39     parser_migrate = subparsers.add_parser('migrate')
40     parser_migrate.set_defaults(which='migrate')
41 
42     parser_start = subparsers.add_parser('start')
43     parser_start.set_defaults(which='start')
44 
45     args = vars(parser.parse_args())
46     config_file = args['ini_file']
47 
48     if args['which'] == 'init':
49         if os.path.exists(config_file):
50             print("%s already exist." % config_file, file=sys.stderr)
51             sys.exit(1)
52 
53         backend = args['backend']
54         if not backend:
55             while True:
56                 prompt = ("Which backend to use? "
57                           "(1 - postgresql, 2 - redis, default - memory) ")
58                 answer = input(prompt).strip()
59                 try:
60                     backends = {"1": "postgresql", "2": "redis", "": "memory"}
61                     backend = backends[answer]
62                     break
63                 except KeyError:
64                     pass
65 
66         init(config_file, backend)
67 
68     elif args['which'] == 'migrate':
69         env = bootstrap(config_file)
70         cliquet.init_schema(env)
71 
72     elif args['which'] == 'start':
73         pserve_argv = ['pserve', config_file, '--reload']
74         pserve.main(pserve_argv)
75 
76 
77 if __name__ == "__main__":
78     main()
79
```
--- 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/kinto/__main__.py b/kinto/__main__.py
--- a/kinto/__main__.py
+++ b/kinto/__main__.py
@@ -2,6 +2,8 @@
 import argparse
 import os
 import sys
+
+import pip
 from six.moves import input
 from cliquet.scripts import cliquet
 from pyramid.scripts import pserve
@@ -65,6 +67,13 @@
 
         init(config_file, backend)
 
+        # Install postgresql libraries if necessary
+        if backend == "postgresql":
+            try:
+                import psycopg2  # NOQA
+            except ImportError:
+                pip.main(['install', "cliquet[postgresql]"])
+
     elif args['which'] == 'migrate':
         env = bootstrap(config_file)
         cliquet.init_schema(env)

{"golden_diff": "diff --git a/kinto/__main__.py b/kinto/__main__.py\n--- a/kinto/__main__.py\n+++ b/kinto/__main__.py\n@@ -2,6 +2,8 @@\n import argparse\n import os\n import sys\n+\n+import pip\n from six.moves import input\n from cliquet.scripts import cliquet\n from pyramid.scripts import pserve\n@@ -65,6 +67,13 @@\n \n         init(config_file, backend)\n \n+        # Install postgresql libraries if necessary\n+        if backend == \"postgresql\":\n+            try:\n+                import psycopg2  # NOQA\n+            except ImportError:\n+                pip.main(['install', \"cliquet[postgresql]\"])\n+\n     elif args['which'] == 'migrate':\n         env = bootstrap(config_file)\n         cliquet.init_schema(env)\n", "issue": "kinto init should install postgresql dependencies\n\n", "before_files": [{"content": "from __future__ import print_function\nimport argparse\nimport os\nimport sys\nfrom six.moves import input\nfrom cliquet.scripts import cliquet\nfrom pyramid.scripts import pserve\nfrom pyramid.paster import bootstrap\n\nfrom kinto.config import init\n\nCONFIG_FILE = 'config/kinto.ini'\n\n\ndef main(args=None):\n    \"\"\"The main routine.\"\"\"\n    if args is None:\n        args = sys.argv[1:]\n\n    parser = argparse.ArgumentParser(description=\"Kinto commands\")\n    parser.add_argument('--ini',\n                        help='Application configuration file',\n                        dest='ini_file',\n                        required=False,\n                        default=CONFIG_FILE)\n    parser.add_argument('--backend',\n                        help='Specify backend',\n                        dest='backend',\n                        required=False,\n                        default=None)\n\n    subparsers = parser.add_subparsers(title='subcommands',\n                                       description='valid subcommands',\n                                       help='init/start/migrate')\n\n    parser_init = subparsers.add_parser('init')\n    parser_init.set_defaults(which='init')\n\n    parser_migrate = subparsers.add_parser('migrate')\n    parser_migrate.set_defaults(which='migrate')\n\n    parser_start = subparsers.add_parser('start')\n    parser_start.set_defaults(which='start')\n\n    args = vars(parser.parse_args())\n    config_file = args['ini_file']\n\n    if args['which'] == 'init':\n        if os.path.exists(config_file):\n            print(\"%s already exist.\" % config_file, file=sys.stderr)\n            sys.exit(1)\n\n        backend = args['backend']\n        if not backend:\n            while True:\n                prompt = (\"Which backend to use? \"\n                          \"(1 - postgresql, 2 - redis, default - memory) \")\n                answer = input(prompt).strip()\n                try:\n                    backends = {\"1\": \"postgresql\", \"2\": \"redis\", \"\": \"memory\"}\n                    backend = backends[answer]\n                    break\n                except KeyError:\n                    pass\n\n        init(config_file, backend)\n\n    elif args['which'] == 'migrate':\n        env = bootstrap(config_file)\n        cliquet.init_schema(env)\n\n    elif args['which'] == 'start':\n        pserve_argv = ['pserve', config_file, '--reload']\n        pserve.main(pserve_argv)\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "kinto/__main__.py"}], "after_files": [{"content": "from __future__ import print_function\nimport argparse\nimport os\nimport sys\n\nimport pip\nfrom six.moves import input\nfrom cliquet.scripts import cliquet\nfrom pyramid.scripts import pserve\nfrom pyramid.paster import bootstrap\n\nfrom kinto.config import init\n\nCONFIG_FILE = 'config/kinto.ini'\n\n\ndef main(args=None):\n    \"\"\"The main routine.\"\"\"\n    if args is None:\n        args = sys.argv[1:]\n\n    parser = argparse.ArgumentParser(description=\"Kinto commands\")\n    parser.add_argument('--ini',\n                        help='Application configuration file',\n                        dest='ini_file',\n                        required=False,\n                        default=CONFIG_FILE)\n    parser.add_argument('--backend',\n                        help='Specify backend',\n                        dest='backend',\n                        required=False,\n                        default=None)\n\n    subparsers = parser.add_subparsers(title='subcommands',\n                                       description='valid subcommands',\n                                       help='init/start/migrate')\n\n    parser_init = subparsers.add_parser('init')\n    parser_init.set_defaults(which='init')\n\n    parser_migrate = subparsers.add_parser('migrate')\n    parser_migrate.set_defaults(which='migrate')\n\n    parser_start = subparsers.add_parser('start')\n    parser_start.set_defaults(which='start')\n\n    args = vars(parser.parse_args())\n    config_file = args['ini_file']\n\n    if args['which'] == 'init':\n        if os.path.exists(config_file):\n            print(\"%s already exist.\" % config_file, file=sys.stderr)\n            sys.exit(1)\n\n        backend = args['backend']\n        if not backend:\n            while True:\n                prompt = (\"Which backend to use? \"\n                          \"(1 - postgresql, 2 - redis, default - memory) \")\n                answer = input(prompt).strip()\n                try:\n                    backends = {\"1\": \"postgresql\", \"2\": \"redis\", \"\": \"memory\"}\n                    backend = backends[answer]\n                    break\n                except KeyError:\n                    pass\n\n        init(config_file, backend)\n\n        # Install postgresql libraries if necessary\n        if backend == \"postgresql\":\n            try:\n                import psycopg2  # NOQA\n            except ImportError:\n                pip.main(['install', \"cliquet[postgresql]\"])\n\n    elif args['which'] == 'migrate':\n        env = bootstrap(config_file)\n        cliquet.init_schema(env)\n\n    elif args['which'] == 'start':\n        pserve_argv = ['pserve', config_file, '--reload']\n        pserve.main(pserve_argv)\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "kinto/__main__.py"}]}