This file is indexed.

/usr/share/doc/python-psycopg2-doc/html/install.html is in python-psycopg2-doc 2.7.4-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Introduction &#8212; Psycopg 2.7.4 documentation</title>
    <link rel="stylesheet" href="_static/psycopg.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '2.7.4',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true,
        SOURCELINK_SUFFIX: '.txt'
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="Basic module usage" href="usage.html" />
    <link rel="prev" title="Psycopg – PostgreSQL database adapter for Python" href="index.html" /> 
  </head>
  <body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="usage.html" title="Basic module usage"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="index.html" title="Psycopg – PostgreSQL database adapter for Python"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">Psycopg 2.7.4 documentation</a> &#187;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="introduction">
<h1>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline"></a></h1>
<p>Psycopg is a <a class="reference external" href="http://www.postgresql.org/">PostgreSQL</a> adapter for the <a class="reference external" href="http://www.python.org/">Python</a> programming language. It is a
wrapper for the <a class="reference external" href="http://www.postgresql.org/docs/current/static/libpq.html">libpq</a>, the official PostgreSQL client library.</p>
<p>The <a class="reference internal" href="module.html#module-psycopg2" title="psycopg2"><code class="xref py py-obj docutils literal"><span class="pre">psycopg2</span></code></a> package is the current mature implementation of the adapter: it
is a C extension and as such it is only compatible with <a class="reference external" href="http://en.wikipedia.org/wiki/CPython">CPython</a>. If you want
to use Psycopg on a different Python implementation (PyPy, Jython, IronPython)
there is an experimental <a class="reference external" href="https://github.com/mvantellingen/psycopg2-ctypes">porting of Psycopg for Ctypes</a>, but it is not as
mature as the C implementation yet.</p>
<div class="section" id="prerequisites">
<span id="index-0"></span><h2>Prerequisites<a class="headerlink" href="#prerequisites" title="Permalink to this headline"></a></h2>
<p>The current <code class="xref py py-obj docutils literal"><span class="pre">psycopg2</span></code> implementation supports:</p>
<ul class="simple">
<li>Python 2 versions from 2.6 to 2.7</li>
<li>Python 3 versions from 3.2 to 3.6</li>
<li>PostgreSQL server versions from 7.4 to 10</li>
<li>PostgreSQL client library version from 9.1</li>
</ul>
<div class="section" id="build-prerequisites">
<span id="id2"></span><h3>Build prerequisites<a class="headerlink" href="#build-prerequisites" title="Permalink to this headline"></a></h3>
<p>The build prerequisites are to be met in order to install Psycopg from source
code, either from a source distribution package or from PyPI.</p>
<p>Psycopg is a C wrapper around the <a class="reference external" href="http://www.postgresql.org/docs/current/static/libpq.html">libpq</a> PostgreSQL client library. To install
it from sources you will need:</p>
<ul>
<li><p class="first">A C compiler.</p>
</li>
<li><p class="first">The Python header files. They are usually installed in a package such as
<strong>python-dev</strong>. A message such as <em>error: Python.h: No such file or
directory</em> is an indication that the Python headers are missing.</p>
</li>
<li><p class="first">The libpq header files. They are usually installed in a package such as
<strong>libpq-dev</strong>. If you get an <em>error: libpq-fe.h: No such file or directory</em>
you are missing them.</p>
</li>
<li><p class="first">The <strong class="program">pg_config</strong> program: it is usually installed by the
<strong>libpq-dev</strong> package but sometimes it is not in a <span class="target" id="index-1"></span><code class="xref std std-envvar docutils literal"><span class="pre">PATH</span></code> directory.
Having it in the <span class="target" id="index-2"></span><code class="xref std std-envvar docutils literal"><span class="pre">PATH</span></code> greatly streamlines the installation, so try
running <code class="docutils literal"><span class="pre">pg_config</span> <span class="pre">--version</span></code>: if it returns an error or an unexpected
version number then locate the directory containing the <strong class="program">pg_config</strong>
shipped with the right libpq version (usually
<code class="docutils literal"><span class="pre">/usr/lib/postgresql/X.Y/bin/</span></code>) and add it to the <span class="target" id="index-3"></span><code class="xref std std-envvar docutils literal"><span class="pre">PATH</span></code>:</p>
<div class="highlight-console"><div class="highlight"><pre><span></span><span class="gp">$</span> <span class="nb">export</span> <span class="nv">PATH</span><span class="o">=</span>/usr/lib/postgresql/X.Y/bin/:<span class="nv">$PATH</span>
</pre></div>
</div>
<p>You only need <strong class="program">pg_config</strong> to compile <code class="xref py py-obj docutils literal"><span class="pre">psycopg2</span></code>, not for its
regular usage.</p>
</li>
</ul>
<p>Once everything is in place it’s just a matter of running the standard:</p>
<div class="highlight-console"><div class="highlight"><pre><span></span><span class="gp">$</span> pip install psycopg2
</pre></div>
</div>
<p>or, from the directory containing the source code:</p>
<div class="highlight-console"><div class="highlight"><pre><span></span><span class="gp">$</span> python setup.py build
<span class="gp">$</span> python setup.py install
</pre></div>
</div>
</div>
<div class="section" id="runtime-requirements">
<h3>Runtime requirements<a class="headerlink" href="#runtime-requirements" title="Permalink to this headline"></a></h3>
<p>Unless you compile <code class="xref py py-obj docutils literal"><span class="pre">psycopg2</span></code> as a static library, or you install it from a
self-contained wheel package, it will need the <a class="reference external" href="http://www.postgresql.org/docs/current/static/libpq.html">libpq</a> library at runtime
(usually distributed in a <code class="docutils literal"><span class="pre">libpq.so</span></code> or <code class="docutils literal"><span class="pre">libpq.dll</span></code> file).  <code class="xref py py-obj docutils literal"><span class="pre">psycopg2</span></code>
relies on the host OS to find the library if the library is installed in a
standard location there is usually no problem; if the library is in a
non-standard location you will have to tell somehow Psycopg how to find it,
which is OS-dependent (for instance setting a suitable
<span class="target" id="index-4"></span><code class="xref std std-envvar docutils literal"><span class="pre">LD_LIBRARY_PATH</span></code> on Linux).</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The libpq header files used to compile <code class="xref py py-obj docutils literal"><span class="pre">psycopg2</span></code> should match the
version of the library linked at runtime. If you get errors about missing
or mismatching libraries when importing <code class="xref py py-obj docutils literal"><span class="pre">psycopg2</span></code> check (e.g. using
<strong class="program">ldd</strong>) if the module <code class="docutils literal"><span class="pre">psycopg2/_psycopg.so</span></code> is linked to the
right <code class="docutils literal"><span class="pre">libpq.so</span></code>.</p>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Whatever version of libpq <code class="xref py py-obj docutils literal"><span class="pre">psycopg2</span></code> is compiled with, it will be
possible to connect to PostgreSQL servers of any supported version: just
install the most recent libpq version or the most practical, without
trying to match it to the version of the PostgreSQL server you will have
to connect to.</p>
</div>
</div>
</div>
<div class="section" id="binary-install-from-pypi">
<span id="index-5"></span><h2>Binary install from PyPI<a class="headerlink" href="#binary-install-from-pypi" title="Permalink to this headline"></a></h2>
<p><code class="xref py py-obj docutils literal"><span class="pre">psycopg2</span></code> is also <a class="reference external" href="https://pypi.python.org/pypi/psycopg2-binary/">available on PyPI</a> in the form of <a class="reference external" href="http://pythonwheels.com/">wheel</a> packages for
the most common platform (Linux, OSX, Windows): this should make you able to
install a binary version of the module, not requiring the above build or
runtime prerequisites, simply using:</p>
<div class="highlight-console"><div class="highlight"><pre><span></span><span class="gp">$</span> pip install psycopg2-binary
</pre></div>
</div>
<p>Make sure to use an up-to-date version of <strong class="program">pip</strong> (you can upgrade it
using something like <code class="docutils literal"><span class="pre">pip</span> <span class="pre">install</span> <span class="pre">-U</span> <span class="pre">pip</span></code>)</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The binary packages come with their own versions of a few C libraries,
among which <code class="docutils literal"><span class="pre">libpq</span></code> and <code class="docutils literal"><span class="pre">libssl</span></code>, which will be used regardless of other
libraries available on the client: upgrading the system libraries will not
upgrade the libraries used by <code class="xref py py-obj docutils literal"><span class="pre">psycopg2</span></code>. Please build <code class="xref py py-obj docutils literal"><span class="pre">psycopg2</span></code> from
source if you want to maintain binary upgradeability.</p>
</div>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">The <code class="xref py py-obj docutils literal"><span class="pre">psycopg2</span></code> wheel package comes packaged, among the others, with its
own <code class="docutils literal"><span class="pre">libssl</span></code> binary. This may create conflicts with other extension
modules binding with <code class="docutils literal"><span class="pre">libssl</span></code> as well, for instance with the Python
<a class="reference external" href="/usr/share/doc/python3-doc/html/library/ssl.html#module-ssl" title="(in Python v3.6)"><code class="xref py py-obj docutils literal"><span class="pre">ssl</span></code></a> module: in some cases, under concurrency, the interaction between
the two libraries may result in a segfault. In case of doubts you are
advised to use a package built from source.</p>
</div>
<div class="section" id="disabling-wheel-packages-for-psycopg-2-7">
<span id="disable-wheel"></span><span id="index-6"></span><h3>Disabling wheel packages for Psycopg 2.7<a class="headerlink" href="#disabling-wheel-packages-for-psycopg-2-7" title="Permalink to this headline"></a></h3>
<p>In version 2.7.x, <code class="xref py py-obj docutils literal"><span class="pre">pip</span> <span class="pre">install</span> <span class="pre">psycopg2</span></code> would have tried to install the wheel
binary package of Psycopg. Because of the problems the wheel package have
displayed, <code class="xref py py-obj docutils literal"><span class="pre">psycopg2-binary</span></code> has become a separate package, and from 2.8 it
has become the only way to install the binary package.</p>
<p>If you are using psycopg 2.7 and you want to disable the use of wheel binary
packages, relying on the system system libraries available on your client, you
can use the <strong class="command">pip</strong> <a class="reference external" href="https://pip.pypa.io/en/stable/reference/pip_install/#install-no-binary"><code class="docutils literal"><span class="pre">--no-binary</span></code> option</a>:</p>
<div class="highlight-console"><div class="highlight"><pre><span></span><span class="gp">$</span> pip install --no-binary psycopg2
</pre></div>
</div>
<p>which can be specified in your <code class="file docutils literal"><span class="pre">requirements.txt</span></code> files too, e.g. use:</p>
<div class="highlight-none"><div class="highlight"><pre><span></span>psycopg2&gt;=2.7,&lt;2.8 --no-binary psycopg2
</pre></div>
</div>
<p>to use the last bugfix release of the <code class="xref py py-obj docutils literal"><span class="pre">psycopg2</span></code> 2.7 package, specifying to
always compile it from source. Of course in this case you will have to meet
the <a class="reference internal" href="#build-prerequisites"><span class="std std-ref">build prerequisites</span></a>.</p>
</div>
</div>
<div class="section" id="non-standard-builds">
<span id="index-7"></span><h2>Non-standard builds<a class="headerlink" href="#non-standard-builds" title="Permalink to this headline"></a></h2>
<p>If you have less standard requirements such as:</p>
<ul class="simple">
<li>creating a <a class="reference internal" href="#debug-build"><span class="std std-ref">debug build</span></a>,</li>
<li>using <strong class="program">pg_config</strong> not in the <span class="target" id="index-8"></span><code class="xref std std-envvar docutils literal"><span class="pre">PATH</span></code>,</li>
<li>supporting <code class="docutils literal"><span class="pre">mx.DateTime</span></code>,</li>
</ul>
<p>then take a look at the <code class="docutils literal"><span class="pre">setup.cfg</span></code> file.</p>
<p>Some of the options available in <code class="docutils literal"><span class="pre">setup.cfg</span></code> are also available as command
line arguments of the <code class="docutils literal"><span class="pre">build_ext</span></code> sub-command. For instance you can specify
an alternate <strong class="program">pg_config</strong> location using:</p>
<div class="highlight-console"><div class="highlight"><pre><span></span><span class="gp">$</span> python setup.py build_ext --pg-config /path/to/pg_config build
</pre></div>
</div>
<p>Use <code class="docutils literal"><span class="pre">python</span> <span class="pre">setup.py</span> <span class="pre">build_ext</span> <span class="pre">--help</span></code> to get a list of the options
supported.</p>
<div class="section" id="creating-a-debug-build">
<span id="debug-build"></span><span id="index-9"></span><h3>Creating a debug build<a class="headerlink" href="#creating-a-debug-build" title="Permalink to this headline"></a></h3>
<p>In case of problems, Psycopg can be configured to emit detailed debug
messages, which can be very useful for diagnostics and to report a bug. In
order to create a debug package:</p>
<ul class="simple">
<li><a class="reference external" href="http://initd.org/psycopg/download/">Download</a> and unpack the Psycopg source package.</li>
<li>Edit the <code class="docutils literal"><span class="pre">setup.cfg</span></code> file adding the <code class="docutils literal"><span class="pre">PSYCOPG_DEBUG</span></code> flag to the
<code class="docutils literal"><span class="pre">define</span></code> option.</li>
<li><a class="reference internal" href="#build-prerequisites"><span class="std std-ref">Compile and install</span></a> the package.</li>
<li>Set the <span class="target" id="index-10"></span><code class="xref std std-envvar docutils literal"><span class="pre">PSYCOPG_DEBUG</span></code> environment variable:</li>
</ul>
<div class="highlight-console"><div class="highlight"><pre><span></span><span class="gp">$</span> <span class="nb">export</span> <span class="nv">PSYCOPG_DEBUG</span><span class="o">=</span><span class="m">1</span>
</pre></div>
</div>
<ul class="simple">
<li>Run your program (making sure that the <code class="xref py py-obj docutils literal"><span class="pre">psycopg2</span></code> package imported is the
one you just compiled and not e.g. the system one): you will have a copious
stream of informations printed on stderr.</li>
</ul>
</div>
</div>
<div class="section" id="running-the-test-suite">
<span id="test-suite"></span><span id="index-11"></span><h2>Running the test suite<a class="headerlink" href="#running-the-test-suite" title="Permalink to this headline"></a></h2>
<p>Once <code class="xref py py-obj docutils literal"><span class="pre">psycopg2</span></code> is installed you can run the test suite to verify it is
working correctly. You can run:</p>
<div class="highlight-console"><div class="highlight"><pre><span></span><span class="gp">$</span> python -c <span class="s2">&quot;from psycopg2 import tests; tests.unittest.main(defaultTest=&#39;tests.test_suite&#39;)&quot;</span> --verbose
</pre></div>
</div>
<p>The tests run against a database called <code class="docutils literal"><span class="pre">psycopg2_test</span></code> on UNIX socket and
the standard port. You can configure a different database to run the test by
setting the environment variables:</p>
<ul class="simple">
<li><span class="target" id="index-12"></span><code class="xref std std-envvar docutils literal"><span class="pre">PSYCOPG2_TESTDB</span></code></li>
<li><span class="target" id="index-13"></span><code class="xref std std-envvar docutils literal"><span class="pre">PSYCOPG2_TESTDB_HOST</span></code></li>
<li><span class="target" id="index-14"></span><code class="xref std std-envvar docutils literal"><span class="pre">PSYCOPG2_TESTDB_PORT</span></code></li>
<li><span class="target" id="index-15"></span><code class="xref std std-envvar docutils literal"><span class="pre">PSYCOPG2_TESTDB_USER</span></code></li>
</ul>
<p>The database should already exist before running the tests.</p>
</div>
<div class="section" id="if-you-still-have-problems">
<span id="other-problems"></span><h2>If you still have problems<a class="headerlink" href="#if-you-still-have-problems" title="Permalink to this headline"></a></h2>
<p>Try the following. <em>In order:</em></p>
<ul class="simple">
<li>Read again the <a class="reference internal" href="#build-prerequisites"><span class="std std-ref">Build prerequisites</span></a>.</li>
<li>Read the <a class="reference internal" href="faq.html#faq-compile"><span class="std std-ref">FAQ</span></a>.</li>
<li>Google for <code class="xref py py-obj docutils literal"><span class="pre">psycopg2</span></code> <em>your error message</em>. Especially useful the week
after the release of a new OS X version.</li>
<li>Write to the <a class="reference external" href="https://lists.postgresql.org/mj/mj_wwwusr?func=lists-long-full&amp;extra=psycopg">Mailing List</a>.</li>
<li>Complain on your blog or on Twitter that <code class="xref py py-obj docutils literal"><span class="pre">psycopg2</span></code> is the worst package
ever and about the quality time you have wasted figuring out the correct
<span class="target" id="index-16"></span><code class="xref std std-envvar docutils literal"><span class="pre">ARCHFLAGS</span></code>. Especially useful from the Starbucks near you.</li>
</ul>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Introduction</a><ul>
<li><a class="reference internal" href="#prerequisites">Prerequisites</a><ul>
<li><a class="reference internal" href="#build-prerequisites">Build prerequisites</a></li>
<li><a class="reference internal" href="#runtime-requirements">Runtime requirements</a></li>
</ul>
</li>
<li><a class="reference internal" href="#binary-install-from-pypi">Binary install from PyPI</a><ul>
<li><a class="reference internal" href="#disabling-wheel-packages-for-psycopg-2-7">Disabling wheel packages for Psycopg 2.7</a></li>
</ul>
</li>
<li><a class="reference internal" href="#non-standard-builds">Non-standard builds</a><ul>
<li><a class="reference internal" href="#creating-a-debug-build">Creating a debug build</a></li>
</ul>
</li>
<li><a class="reference internal" href="#running-the-test-suite">Running the test suite</a></li>
<li><a class="reference internal" href="#if-you-still-have-problems">If you still have problems</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="index.html"
                        title="previous chapter">Psycopg – PostgreSQL database adapter for Python</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="usage.html"
                        title="next chapter">Basic module usage</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="_sources/install.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <div><input type="text" name="q" /></div>
      <div><input type="submit" value="Go" /></div>
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="usage.html" title="Basic module usage"
             >next</a> |</li>
        <li class="right" >
          <a href="index.html" title="Psycopg – PostgreSQL database adapter for Python"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">Psycopg 2.7.4 documentation</a> &#187;</li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2001-2018, Federico Di Gregorio, Daniele Varrazzo.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.6.6.
    </div>
  </body>
</html>