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/__init__.py", 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/_psycopg.so: 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 _psycopg.so and check which libpq.so it is looking for, if there are several in your system and if the right one was chosen. You can use ldd on libpq.so 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/libpq.so shows the dependency:

    libgssapi_krb5.so.2 => /usr/lib/i386-linux-gnu/libgssapi_krb5.so.2 (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

    linux-gate.so.1 =>  (0x00c8a000)
    libpython2.6.so.1.0 => /usr/lib/libpython2.6.so.1.0 (0x005f5000)
    libpthread.so.0 => /lib/libpthread.so.0 (0x00a98000)
    libc.so.6 => /lib/libc.so.6 (0x00d10000)
    libdl.so.2 => /lib/libdl.so.2 (0x001cd000)
    libutil.so.1 => /lib/libutil.so.1 (0x003a9000)
    libm.so.6 => /lib/libm.so.6 (0x00ca9000)
    /lib/ld-linux.so.2 (0x00af9000)
    

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

    /usr/pgsql-9.1/lib/libpq.so

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

    lucas

  • Stephen Lukacs

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

    oh and i forgot to add ldd libpq.so, which returns:

    linux-gate.so.1 =>  (0x0049a000)
    libssl.so.10 => /usr/lib/libssl.so.10 (0x00407000)
    libcrypto.so.10 => /usr/lib/libcrypto.so.10 (0x00110000)
    libgssapi_krb5.so.2 => /lib/libgssapi_krb5.so.2 (0x004bf000)
    libldap_r-2.4.so.2 => /lib/libldap_r-2.4.so.2 (0x00db6000)
    libpthread.so.0 => /lib/libpthread.so.0 (0x00371000)
    libc.so.6 => /lib/libc.so.6 (0x004fe000)
    libkrb5.so.3 => /lib/libkrb5.so.3 (0x009b3000)
    libcom_err.so.2 => /lib/libcom_err.so.2 (0x0029d000)
    libk5crypto.so.3 => /lib/libk5crypto.so.3 (0x00f61000)
    libresolv.so.2 => /lib/libresolv.so.2 (0x00fcd000)
    libdl.so.2 => /lib/libdl.so.2 (0x00c04000)
    libz.so.1 => /lib/libz.so.1 (0x002a2000)
    libkrb5support.so.0 => /lib/libkrb5support.so.0 (0x002b6000)
    libkeyutils.so.1 => /lib/libkeyutils.so.1 (0x002c1000)
    liblber-2.4.so.2 => /lib/liblber-2.4.so.2 (0x002c5000)
    libssl3.so => /usr/lib/libssl3.so (0x002d4000)
    libsmime3.so => /usr/lib/libsmime3.so (0x00e21000)
    libnss3.so => /usr/lib/libnss3.so (0x00694000)
    libnssutil3.so => /usr/lib/libnssutil3.so (0x00aba000)
    libplds4.so => /lib/libplds4.so (0x00853000)
    libplc4.so => /lib/libplc4.so (0x00310000)
    libnspr4.so => /lib/libnspr4.so (0x00316000)
    libsasl2.so.2 => /usr/lib/libsasl2.so.2 (0x00354000)
    /lib/ld-linux.so.2 (0x00af9000)
    libselinux.so.1 => /lib/libselinux.so.1 (0x0038c000)
    libcrypt.so.1 => /lib/libcrypt.so.1 (0x0096d000)
    libfreebl3.so => /lib/libfreebl3.so (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 libgssapi_krb5.so.2 -> libgssapi_krb5.so.2.2
    -rwxr-xr-x 1 root root 255968 Jul 31 14:58 libgssapi_krb5.so.2.2

    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 _psycopg.so 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 libpq.so 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="https://github.com/psycopg/psycopg2/issues">the new tracker</a>.
<br/>
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

Pages