Обсуждение: Installation of psycopg2
Hi Team,
I am trying to connect to PostgreSQL from python.
I have post PostgreSQL gres database version 8.1 and python 3.5 (earlier version for python 2.4, default installation on unix is also present)
Direct internet connectivity from the organization is not allowed so I have to go through installation using setup.py.
Now, I am facing issue when I run command
python3.5 /usr/local/bin/psycopg2-2.7.3.2/setup.py install
running build_ext building 'psycopg2._psycopg' extension creating build/temp.linux-x86_64-3.5 creating build/temp.linux-x86_64-3.5/psycopg gcc*** command here In file included from psycopg/psycopgmodule.c:27: ./psycopg/psycopg.h:30:2: error: #error "Psycopg requires PostgreSQL client library (libpq) >= 9.1"
I checked for path for pg_config is there in path variable as '/usr/bin/'.
Can you suggest on below
1. How can I resolve this error?
2. why error say Psycopg instead of Psycopg2
3. will package work with PostgreSQL 8.1 database
Your help will be much appreciated. Let me know if you any further inputs.
Thanks in advance.
Regards
Nitesh Jain
On Mon, Feb 5, 2018 at 11:28 AM, Nitesh Jain <nitesh.learning@gmail.com> wrote: > Hi Team, > > I am trying to connect to PostgreSQL from python. > I have post PostgreSQL gres database version 8.1 and python 3.5 (earlier > version for python 2.4, default installation on unix is also present) > > Direct internet connectivity from the organization is not allowed so I have > to go through installation using setup.py. > > Now, I am facing issue when I run command > python3.5 /usr/local/bin/psycopg2-2.7.3.2/setup.py install > > running build_ext building 'psycopg2._psycopg' extension creating > build/temp.linux-x86_64-3.5 creating build/temp.linux-x86_64-3.5/psycopg > gcc*** command here In file included from psycopg/psycopgmodule.c:27: > ./psycopg/psycopg.h:30:2: error: #error "Psycopg requires PostgreSQL client > library (libpq) >= 9.1" > > I checked for path for pg_config is there in path variable as '/usr/bin/'. > > Can you suggest on below > 1. How can I resolve this error? > 2. why error say Psycopg instead of Psycopg2 > 3. will package work with PostgreSQL 8.1 database > > Your help will be much appreciated. Let me know if you any further inputs. > Thanks in advance. Hello Nitesh, first, as a word of advice, PostgreSQL 8.1 is long unmaintained; it would be better to update your servers to a maintained version. Anyway I believe the choice is not yours, so let's go ahead. Psycopg 2.7 depends on the postgres *client library* (libpq) version >= 9.1, so packages such as postgresql-client and libpq-dev should be at least this version. This is independent from your server version: once you build successfully the library on the client you will be able to connect to any server with version >= 7.4. So, in order to solve your problem, either you install Psycopg 2.6, or you install the postgres client package 9.1. Both solution are something you have to do on the client. In both cases yes, you will be able to connect and use a server 8.1. What's in the error message is just a typo :) Hope this helps -- Daniele
Hi Daniele,
can you suggest, how can I check version for libpq or libpq-dev?
Any idea if I can only install libpq 9.1 version?
On Mon, Feb 5, 2018 at 5:21 PM, Daniele Varrazzo <daniele.varrazzo@gmail.com> wrote:
On Mon, Feb 5, 2018 at 11:28 AM, Nitesh Jain <nitesh.learning@gmail.com> wrote:
> Hi Team,
>
> I am trying to connect to PostgreSQL from python.
> I have post PostgreSQL gres database version 8.1 and python 3.5 (earlier
> version for python 2.4, default installation on unix is also present)
>
> Direct internet connectivity from the organization is not allowed so I have
> to go through installation using setup.py.
>
> Now, I am facing issue when I run command
> python3.5 /usr/local/bin/psycopg2-2.7.3.2/setup.py install
>
> running build_ext building 'psycopg2._psycopg' extension creating
> build/temp.linux-x86_64-3.5 creating build/temp.linux-x86_64-3.5/psycopg
> gcc*** command here In file included from psycopg/psycopgmodule.c:27:
> ./psycopg/psycopg.h:30:2: error: #error "Psycopg requires PostgreSQL client
> library (libpq) >= 9.1"
>
> I checked for path for pg_config is there in path variable as '/usr/bin/'.
>
> Can you suggest on below
> 1. How can I resolve this error?
> 2. why error say Psycopg instead of Psycopg2
> 3. will package work with PostgreSQL 8.1 database
>
> Your help will be much appreciated. Let me know if you any further inputs.
> Thanks in advance.
Hello Nitesh,
first, as a word of advice, PostgreSQL 8.1 is long unmaintained; it
would be better to update your servers to a maintained version. Anyway
I believe the choice is not yours, so let's go ahead.
Psycopg 2.7 depends on the postgres *client library* (libpq) version
>= 9.1, so packages such as postgresql-client and libpq-dev should be
at least this version. This is independent from your server version:
once you build successfully the library on the client you will be able
to connect to any server with version >= 7.4.
So, in order to solve your problem, either you install Psycopg 2.6, or
you install the postgres client package 9.1. Both solution are
something you have to do on the client. In both cases yes, you will be
able to connect and use a server 8.1.
What's in the error message is just a typo :)
Hope this helps
-- Daniele
On Mon, Feb 5, 2018 at 2:57 PM, Nitesh Jain <nitesh.learning@gmail.com> wrote: > Hi Daniele, > > can you suggest, how can I check version for libpq or libpq-dev? > Any idea if I can only install libpq 9.1 version? pg_config --version will tell you what is the client library that psycopg will use to build. how to install a specific version for your client depends on the OS you are using. On Debian/Ubuntu you will need an updated libpq-dev package. Google can provide you more information than what I can. -- Daniele