开发者

"undefined symbol: _PyObject_NextNotImplemented" error when loading psycopg2 module

environment: Ubuntu 10.04 LTS
build Python 2.7.2 wi开发者_如何学编程th ./configure --with-zlib --enable-unicode=ucs4
postgresql-9.0
wsgi
Django 1.3
virtualenv
apache

I am trying to build Ubuntu Django App Server. The installation completed with no error message. The exact installation method was successful with Ubuntu 11.04. However, when installation is completed on Ubuntu 10.04 and try to load psycopg2 from Django, I got the following error (I did not get this error on 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

My guess is that some linkage to library is incorrect... but I have no idea where to start... I have a following output - 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 command outputs:

$ 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

To me it appears that all is correct. Any advice would be appreciated.


You mention 'wsgi' as a tag. If that means you are using Apache/mod_wsgi then be aware that mod_wsgi must be compiled against the same Python version/installation and you need to verify that mod_wsgi is picking up the same libpython.so at run time as it is mod_wsgi that dictates the Python library linked in.


[SOLVED] Thanks to both patrys and Graham Dumpleton, it was clear that my custom build Python 2.7 and wsgi installation was wrong and critical library linking was absent. Now the problem is resolved by following the instruction below resolved this issue. Thanks to all smart and kind people who is sharing information.

  1. Reinstall Python: https://askubuntu.com/questions/17841/will-python2-7-be-available-for-lucid-in-future

  2. Then uninstall WSGI: sudo apt-get purge libapache2-mod-wsgi

  3. Install WSGI: http://grok.zope.org/documentation/tutorial/installing-and-setting-up-grok-under-mod-wsgi/installing-and-configuring-mod-wsgi


This particular symbol comes from libpython*.*.so.1.0 (replace wildcards with your version of python). You should see it when listing dynamic symbols using 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

Are you using a custom build? It seems your version of _psycopg.so is not linked to libpython at all.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜