"undefined symbol: _PyObject_NextNotImplemented" error loading psycopg2 module

environment: Ubuntu 10.04 LTS build Python 2.7.2 with ./configure --with-zlib --enable-unicode=ucs4 postgresql-9.0 wsgi Django 1.3 virtualenv apache 

I am trying to create an Ubuntu Django App Server. Installation completed without error message. The exact installation method has been successful since Ubuntu 11.04. However, when the installation is completed on Ubuntu 10.04 and try downloading psycopg2 from Django, I received the following error (I did not receive this error 11.04):

 File "/home/nreeves/venv/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 24, in <module> raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e) ImproperlyConfigured: Error loading psycopg2 module: /home/nreeves/venv/lib/python2.7/site-packages/psycopg2/_psycopg.so: undefined symbol: _PyObject_NextNotImplemented 

I guess some library binding is wrong ... but I have no idea where to start ... I have the following conclusion - I'm not sure if this will help you help me ...

 $ ldd /home/nreeves/venv/lib/python2.7/site-packages/psycopg2/_psycopg.so linux-gate.so.1 => (0xb77da000) libpq.so.5 => /usr/lib/libpq.so.5 (0xb7788000) libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb776f000) libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7614000) libssl.so.0.9.8 => /lib/i686/cmov/libssl.so.0.9.8 (0xb75cc000) libcrypto.so.0.9.8 => /lib/i686/cmov/libcrypto.so.0.9.8 (0xb747a000) libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0xb73c9000) libcom_err.so.2 => /lib/libcom_err.so.2 (0xb73c5000) libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0xb7395000) libldap_r-2.4.so.2 => /usr/lib/libldap_r-2.4.so.2 (0xb734e000) /lib/ld-linux.so.2 (0xb77db000) libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb734a000) libz.so.1 => /lib/libz.so.1 (0xb7335000) libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0xb7311000) libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 (0xb7308000) libkeyutils.so.1 => /lib/libkeyutils.so.1 (0xb7304000) libresolv.so.2 => /lib/tls/i686/cmov/libresolv.so.2 (0xb72f0000) liblber-2.4.so.2 => /usr/lib/liblber-2.4.so.2 (0xb72e3000) libsasl2.so.2 => /usr/lib/libsasl2.so.2 (0xb72cb000) libgnutls.so.26 => /usr/lib/libgnutls.so.26 (0xb722f000) libtasn1.so.3 => /usr/lib/libtasn1.so.3 (0xb721e000) libgcrypt.so.11 => /lib/libgcrypt.so.11 (0xb71ab000) libgpg-error.so.0 => /lib/libgpg-error.so.0 (0xb71a6000) 

And the following commands come out:

 $ ls -l /usr/lib/libpq* -rw-r--r-- 1 root root 224904 2011-09-26 06:33 /usr/lib/libpq.a lrwxrwxrwx 1 root root 12 2011-09-26 10:51 /usr/lib/libpq.so -> libpq.so.5.4 lrwxrwxrwx 1 root root 12 2011-09-26 10:51 /usr/lib/libpq.so.5 -> libpq.so.5.4 -rw-r--r-- 1 root root 150976 2011-09-26 06:33 /usr/lib/libpq.so.5.4 

It seems to me that everything is correct. Any advice would be appreciated.

+4
source share
3 answers

You specify "wsgi" as a tag. If this means that you are using Apache / mod_wsgi, then keep in mind that mod_wsgi must be compiled with the same version / installation of Python, and you need to check that mod_wsgi compiles the same libpython.so at runtime, since it is mod_wsgi, which is dictated by the Python associated with the library.

+4
source

[SOLVED] Thanks to both patrys and Graham Dumpleton, it was clear that my custom builds of Python 2.7 and wsgi were incorrect and there was no critical link to the library. The problem is now resolved by following the instructions below to resolve this problem. Thanks to all smart and kind people who share information.

+2
source

This particular character comes from libpython*.*.so.1.0 (replace wildcards with your python version). You should see this when listing dynamic characters with nm :

 $ ldd /usr/lib64/python2.7/site-packages/psycopg2/_psycopg.so | grep libpython libpython2.7.so.1.0 => /usr/lib64/libpython2.7.so.1.0 (0x00007fe14f0c6000) $ nm -D /usr/lib64/libpython2.7.so.1.0 | grep PyObject_NextNotImplemented 000000000008a880 T _PyObject_NextNotImplemented 

Do you use custom assembly? It seems your version of _psycopg.so is not related to libpython at libpython .

+1
source

All Articles