python – 加载psycopg2模块时出现“undefined symbol:_PyObject_NextNotImplemented”错误

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

我正在尝试构建Ubuntu Django App Server.安装完成,没有错误消息. Ubuntu 11.04的确切安装方法是成功的.
但是,当在Ubuntu 10.04上完成安装并尝试从Django加载psycopg2时,我收到以下错误(我在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

我的猜测是与图书馆的某些联系不正确…但我不知道从哪里开始…我有一个以下输出 – 不确定这是否会帮助你帮助我…

$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)

以下命令输出:

$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

对我而言似乎一切都是正确的.任何意见,将不胜感激.

解决方法:

你提到’wsgi’作为标签.如果这意味着您正在使用Apache / mod_wsgi,那么请注意mod_wsgi必须针对相同的Python版本/安装进行编译,并且您需要验证mod_wsgi是否在运行时获取相同的libpython.so,因为它是指示Python的mod_wsgi图书馆链接.

上一篇:python – 使用CherryPy的HTTPS到HTTP


下一篇:nginx+uWSGI+django+virtualenv+supervisor发布web服务器