postgresql psycopg2 install

Hi
All I want to do is run Django on opensuse 11.2.

I have python2.6 installed via yast
I have postgresql8.4 installed via yast.

Now psycopg is some sort of glue that django needs to connect to postgres. I’ve downloaded it but I now need to build and install. It can’t find what it needs and they what it needs doesn’t seem to be in suse install sites.

It seems that it needs libpq-fe.h
I couldn’t find any package that may have it (it’s probably in a package named libpq-dev (apparently that’s a Q in libpq, not a G as one would expect…). anyway neither libpq-dev nor libpg-dev is available from a suse site.

I found the contents of the header file and took a chance and put it in the psycopg2 directory. The builder thought that was ok and then couldn’t find pg_config. That also seems to be not found on suse install sites.

Can anyone give me a few clues as to how to this turkey installed so that I can start doing what I need to do?

many thanks
Mark

Did you try installing postgresql-devel? If you need to compile something (psychopg) against postgres, chances are it’s in a -devel package.

Edit: Also did you try searching on software.opensuse.org. Seems somebody has packaged it:

http://software.opensuse.org/search?q=psycopg2&baseproject=openSUSE:11.2

Many thanks, Ken
It wasn’t in the postgresql-devel package but I found it on http:///software.opensuse.org.
I was stuck. I really appreciate the help.

Dukha

In what package did you find it?

I’ve been stuck for days, now. Tried reverting down to v9.2 (which means I can’t backup from Heroku anymore), but nothing works. We don’t have the ‘libpq-dev’ package available in the other Linux-OSs, which is their universal solution to this problem.

I tried…
zypper search --provides ibpq-fe.hlibpq-dev
Loading repository data…
Reading installed packages…
No packages found.

If you are trying to locate /usr/include/pgsql/libpq-fe.h, it’s contained (in the distribution files too) in postgresql92-devel.

If you want psycopg, it’s directly available via; openSUSE Software

Hi, thank you. I managed to get libpq-fe.h installed by removing all postgres and related and reinstalling. Still get stuck at:

checking for libpq-fe.h… yes
checking for libpq/libpq-fs.h… yes
checking for pg_config_manual.h… yes
checking for PQconnectdb() in -lpq… no
checking for PQconnectdb() in -llibpq… no
checking for PQconnectdb() in -lms/libpq… no
Can’t find the PostgreSQL client library (libpq)

I have pointed it to the correct install of postgresql with:
gem install pg -v ‘0.17.1’ – --with-pg-config=/usr/lib/postgresql93/bin
… but get the same error

This is where the Ubuntu folks install libpq-dev and all is well. What is the opensuse equivalent? I already have postgres-dev.

I can include the mkmf.log output if that will help.

How exactly?
And what version, from where?

I have pointed it to the correct install of postgresql with:
gem install pg -v ‘0.17.1’ – --with-pg-config=/usr/lib/postgresql93/bin
… but get the same error

This is where the Ubuntu folks install libpq-dev and all is well. What is the opensuse equivalent? I already have postgres-dev.

If you installed the openSUSE postgresql-devel package, pg-config should be in /usr/bin/, so you shouldn’t need to specify “–with-pg-config” at all I suppose.
If you compiled/installed postgresql yourself, it would depend on the configure switches you specified. Maybe look into /usr/local in that case, as that’s normally the default.
Try to run “which pg_config” to find out.
Or have a look at the package’s file list, either in YaST or with:

rpm -ql postgresql-devel

(or similar)

I think the libpq package has a bug.

Please check your /usr/lib64/ if the symlink libpq.so is valid - I tested this in a VM and it points to lrwxrwxrwx 1 root root 12 Jul 31 11:39 libpq.so -> libpq.so.5.6 which is incorrect because the file is missing.

libpq.so should point to libpq.so.5.7

Fix the symlink by hand and see if it fixes the issue.

gem install pg -v ‘0.17.1’ – --with-pg-config=/usr/lib/postgresql93/bin --with-opt-include=/usr/include/pgsql

Worked for me after fixing the symlink.

libpg.so is not provided by libpgX, but by postgresqlXX-devel.
If libpgX and postgresqlXX-devel have the exact same version, the link should be correct.
Otherwise it would indeed be a bug of course… :wink:

But I just checked the postgresql93 packages from [noparse]server:database:postgresql[/noparse]: libpq.so from postgresql93-devel does indeed point to libpq.so.5.6, which is actually correct as the corresponding libpg5 package (with the same version 9.3) does contain libpq.so.5.6.

libpq.so.5.7 is only contained in postgresql94 (libpq5-9.4beta1), and postgresql94-devel (version 9.4beta1) does correctly point to libpq.so.5.7.

So you seem to have a version mix there… :wink:

Well, this is why the libraries get mixed up:

mariposa:/usr/lib64 # zypper in postgresql93
Building repository 'PostgreSQL and related packages (openSUSE_13.1)' cache .................................................................................[done]
Loading repository data...
Reading installed packages...
Resolving package dependencies...


The following 2 NEW packages are going to be installed:
  libpq5 postgresql93 


2 new packages to install.
Overall download size: 1.2 MiB. After the operation, additional 4.4 MiB will be used.
Continue? [y/n/? shows all options] (y): y
Retrieving package libpq5-9.4beta1-2.1.x86_64                                                                                 (1/2), 149.5 KiB (465.4 KiB unpacked)
Retrieving: libpq5-9.4beta1-2.1.x86_64.rpm ..................................................................................................................[done]
Retrieving package postgresql93-9.3.5-27.1.x86_64                                                                             (2/2),   1.1 MiB (  4.0 MiB unpacked)
Retrieving: postgresql93-9.3.5-27.1.x86_64.rpm ................................................................................................[done (893.5 KiB/s)]
(1/2) Installing: libpq5-9.4beta1-2.1 .......................................................................................................................[done]
(2/2) Installing: postgresql93-9.3.5-27.1 ...................................................................................................................[done]

mariposa:~ # zypper in postgresql93-devel
Loading repository data...
Reading installed packages...
Resolving package dependencies...


The following 2 NEW packages are going to be installed:
  libecpg6 postgresql93-devel 


2 new packages to install.
Overall download size: 1.0 MiB. After the operation, additional 4.6 MiB will be used.
Continue? [y/n/? shows all options] (y): y
Retrieving package libecpg6-9.4beta1-2.1.x86_64                                                                                       (1/2), 110.2 KiB (210.4 KiB unpacked)
Retrieving: libecpg6-9.4beta1-2.1.x86_64.rpm ........................................................................................................................[done]
Retrieving package postgresql93-devel-9.3.5-27.1.x86_64                                                                               (2/2), 918.1 KiB (  4.4 MiB unpacked)
Retrieving: postgresql93-devel-9.3.5-27.1.x86_64.rpm ....................................................................................................[done (7.7 KiB/s)]
(1/2) Installing: libecpg6-9.4beta1-2.1 .............................................................................................................................[done]
(2/2) Installing: postgresql93-devel-9.3.5-27.1 .....................................................................................................................[done]

It pulls the newest lib instead of libs that match - I didn’t even look at which one it pulled as I assumed it would take the “right one” by default.

What a mess :slight_smile:

To the poster, you need to make sure the libraries that are installed match, so it should look more like this;
mariposa:/usr/lib64 # rpm -qf libpq.so
postgresql93-devel-9.3.5-27.1.x86_64
mariposa:/usr/lib64 # rpm -qf libpq.so.5
libpq5-9.3.5-27.1.x86_64

Thanks Wolfi, almost missed the cause :slight_smile:

Yes, the symlink is wrong:

ls -lah /usr/lib64/libpq*
lrwxrwxrwx 1 root root 12 Jul 31 14:10 /usr/lib64/libpq.so -> libpq.so.5.6
lrwxrwxrwx 1 root root 12 Jul 31 11:49 /usr/lib64/libpq.so.5 -> libpq.so.5.7
-rwxr-xr-x 1 root root 188K May 16 21:47 /usr/lib64/libpq.so.5.7
-rwxr-xr-x 1 root root 358K Jul 30 00:00 /usr/lib64/libpqxx-4.0.so
lrwxrwxrwx 1 root root 14 Jul 31 11:49 /usr/lib64/libpqxx.so -> libpqxx-4.0.so

… and the file is missing.

Changed that so that:

ls -lah libpq*
lrwxrwxrwx 1 root root 14 Jul 31 16:22 libpq.so -> ./libpq.so.5.7
lrwxrwxrwx 1 root root 12 Jul 31 11:49 libpq.so.5 -> libpq.so.5.7
-rwxr-xr-x 1 root root 188K May 16 21:47 libpq.so.5.7
lrwxrwxrwx 1 root root 12 Jul 31 14:10 libpq.so.old -> libpq.so.5.6
-rwxr-xr-x 1 root root 358K Jul 30 00:00 libpqxx-4.0.so
lrwxrwxrwx 1 root root 14 Jul 31 11:49 libpqxx.so -> libpqxx-4.0.so

Then ran your:
gem install pg -v ‘0.17.1’ – --with-pg-config=/usr/lib/postgresql93/bin --with-opt-include=/usr/include/pgsql

THAT WAS IT!! Thank you very much. rotfl!

And yes, this is on PG 9.3, which I returned back to after reverting to v9.2 didn’t help. Specifically, 9.3.5-27.1-x86_64 from vendor obs://build.opensuse.org/server:database

Hi Jack, please check the changes I made to my last post - you just need to make sure both libpq and postgre devel are the same version.

The 5.7 is actually a beta and you should have 5.6 :slight_smile:

Also throw Wolfi some +rep, I would’ve missed it if he hadn’t pointed it out.

Yeah, right. They are both in the same repo and both are named “libpq5”, so zypper takes the higher version (9.4beta1), which is incompatible with postgresql93-devel of course (as it is 9.4).
I suppose part of the reason is that 9.4 is still beta (maybe that’s the reason it is libpq.so.5.7 and not libpq.so.6), but the current situation regarding the repo is of course unacceptable IMHO.

Either the requirements need to be stricter, or the 9.4beta1’s package name should be changed. (libpq57 maybe?)
So this probably warrants a bug report, although that’s “only” a development repo, so it could change anytime.

I do remember some bug report (or was it a mailinglist thread) about the co-installability of the postgresqlXX packages, I have to look if I can find that again.

Ok, but glad I can at least do some work with this mixed-match. Where can I get the libpq.so.5.6 file by itself? I don’t want to break things un/re installing entire packages, but I if I can put than one file in the dir and revert to the old symlink, that would be quick to try (and revert if a problem arises).

Hi Jack,

Since you have Postgre repository added, just run:
zypper in --oldpackage libecpg6=9.3.5 libpq5=9.3.5 postgresql93-devel=9.3.5

That should install 9.3.5 for all required files and you have versions in sync - all pretty 9.3.5’ers. You’ll want to recreate the gem too and check that the symlink now points to 5.6 as it should.

A sidenote: you could also say “<9.4” instead of “=9.3.5”.

And then maybe lock them, so that they don’t get updated to 9.4 again.

zypper al "libpq5>=9.4" "libecpg6>=9.4"

I haven’t tried that, but it should work and should even continue to give you 9.3.x updates if available… :wink:

Another sidenote:
This is apparently no new problem with 94beta1, the package is named “libpq5” in standard openSUSE 13.1 as well (and there it is version 9.2.x with libpq.so.5.5).

"just run:
zypper in --oldpackage libecpg6=9.3.5 libpq5=9.3.5 postgresql93-devel=9.3.5

That worked. Thanks very much.