This project is archived and is in readonly mode.

#121 ✓invalid
Stephen Lukacs

can't import from compile source

Reported by Stephen Lukacs | September 12th, 2012 @ 04:36 AM

i can not import psycopg2 into python 2.6.6 running on centos 6.3 with the upgraded rpms of postgresql 9.1. i downloaded the source for psycopg2 and it compiled and installed ok. however, when i try to import it under python, i get:

Python 2.6.6 (r266:84292, Jun 18 2012, 14:10:23) 
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/site-packages/psycopg2-2.4.5-py2.6-linux-i686.egg/psycopg2/", line 67, in <module>
    from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: /usr/lib/python2.6/site-packages/psycopg2-2.4.5-py2.6-linux-i686.egg/psycopg2/ undefined symbol: GSS_C_NT_HOSTBASED_SERVICE

and i have no idea how to fix it, please advise. lucas

Comments and changes to this ticket

  • Daniele Varrazzo

    Daniele Varrazzo September 12th, 2012 @ 10:05 AM

    Google provides several hits for "undefined symbol: GSS_C_NT_HOSTBASED_SERVICE". They seem related to the libpq and gssapi. The answers are usually "don't compile with gssapi". I assume you haven't compiled the libpq yourself but you are using the packaged one.

    Please try ldd on and check which it is looking for, if there are several in your system and if the right one was chosen. You can use ldd on to check it is the piece with the missing ref.

    Then I don't know: try installing the missing dependency. It could have been a broken upgrade to PG 9.1 or a missing dependency: Devrim Gudunz is the rpm maintainer for postgres and he may know: you may contact him or some other postgres developers e.g. on pgsql-general mailing list with the relevant ldd info for libpq.

    On my system (ubuntu), pg_config --configure shows '--with-gssapi' and as a consequence ldd /usr/lib/ shows the dependency: => /usr/lib/i386-linux-gnu/ (0x003a4000)

    See what happens on yours: I think this is your missing library. Mine was installed by the libgssapi-krb5 package apparently.

  • Stephen Lukacs

    Stephen Lukacs September 12th, 2012 @ 05:07 PM

    ok, so when i do ldd _psycopg2 under /usr/lib/python2.6/site-packages/psycopg2, i get =>  (0x00c8a000) => /usr/lib/ (0x005f5000) => /lib/ (0x00a98000) => /lib/ (0x00d10000) => /lib/ (0x001cd000) => /lib/ (0x003a9000) => /lib/ (0x00ca9000)
    /lib/ (0x00af9000)

    so i don't think i see the file in there at all. how does it even compile then? anyway, my is under


    and it is the only one on my computer, but it is a symbolic link to -> so maybe i need something extra in my setup.cfg file and rerun "python install"? maybe?


  • Stephen Lukacs

    Stephen Lukacs September 12th, 2012 @ 05:09 PM

    oh and i forgot to add ldd, which returns: =>  (0x0049a000) => /usr/lib/ (0x00407000) => /usr/lib/ (0x00110000) => /lib/ (0x004bf000) => /lib/ (0x00db6000) => /lib/ (0x00371000) => /lib/ (0x004fe000) => /lib/ (0x009b3000) => /lib/ (0x0029d000) => /lib/ (0x00f61000) => /lib/ (0x00fcd000) => /lib/ (0x00c04000) => /lib/ (0x002a2000) => /lib/ (0x002b6000) => /lib/ (0x002c1000) => /lib/ (0x002c5000) => /usr/lib/ (0x002d4000) => /usr/lib/ (0x00e21000) => /usr/lib/ (0x00694000) => /usr/lib/ (0x00aba000) => /lib/ (0x00853000) => /lib/ (0x00310000) => /lib/ (0x00316000) => /usr/lib/ (0x00354000)
    /lib/ (0x00af9000) => /lib/ (0x0038c000) => /lib/ (0x0096d000) => /lib/ (0x003ab000)
  • Stephen Lukacs

    Stephen Lukacs September 12th, 2012 @ 05:15 PM

    and under /lib there is:

    lrwxrwxrwx 1 root root 21 Sep 3 04:35 ->
    -rwxr-xr-x 1 root root 255968 Jul 31 14:58

    and i am trying to compile psycopg2 from your download source site because centos 6.x doesn't come with native postgresql 9.1 but instead 8.4, and i used the change to upgrade to 9.1, a bit regrettable at this point, but i am plugging forward until resolved.

  • Daniele Varrazzo

    Daniele Varrazzo September 13th, 2012 @ 12:34 AM

    If libpq is in a non standard place you will have to figure out how to make find it: that sounds a LD_LIBRARY_PATH job, i.e. not a pleasant one. Why don't you just install your libpq in the standard place?

    You can try compiling psycopg with static libpq (see setup.cfg), but I don't know very well how it works on linux. In setup.cfg you can also select the pg_config executable to use. It better be consistent with the libpq provided.

    If you stick to standard postgres installation, psycopg compiles about out of the box. If you have customized dirs for and pg_config you better know your way with dynamic linking, and you are pretty much on your own.

  • Stephen Lukacs

    Stephen Lukacs September 13th, 2012 @ 06:04 AM

    i have been using linux for 15 years. rpms help make sense of all of the packages and yum, and like, help with all of their dependencies. the whole reason i jumped into compiling the psycopg2 driver is because my web2py framework has been crashing and someone suggested i compile psycopg2 from source because i am using the non-native postgresql-9.1 on a centos 6.x server, which the native postgresql is 8.4. but after much run-around with compiling, packages, etc, i found out that the python-psycopg2 rpm that i can install was from the postgresql-9.1 repository anyway, hopefully, allowing me to safely conclude that the psycopg2 driver and its binary libraries are compiled under python 2.6 and my non-native postgresql-9.1. therefore, if my psycopg2 was compiled for my postgresql from the proper postgres repository, i should be safe with using that rpm and psycopg2 driver. and it should therefore be completely stable under web2py. so i don't think i need to compile psycopg2 like i have been attempting because i found the correct one from the right repository. confusing i know but this is the hard part of linux, and it can get frustrating, no? anyway, python is recognizing the rpm psycopg2 fine and so is web2py. so i think i need to look for the instability in web2py somewhere else. thank you for your help and quick responses.

  • Daniele Varrazzo

    Daniele Varrazzo September 13th, 2012 @ 09:09 AM

    • State changed from “new” to “invalid”

    Cool, glad you solved your problem. Next time, for such kind of discussion, try the mailing list, where other people with the relevant knowledge may help you even better (e.g. the author of the rpms reads it).

    Have a nice day!

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

<b>WARNING:</b> the informations in this tracker are archived. Please submit new tickets or comments to <a href="">the new tracker</a>.
Psycopg is the most used PostgreSQL adapter for the Python programming language. At the core it fully implements the Python DB API 2.0 specifications. Several extensions allow access to many of the features offered by PostgreSQL.

Shared Ticket Bins