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
对我而言似乎一切都是正确的。任何建议将不胜感激。
答案 0 :(得分:4)
你提到'wsgi'作为标签。如果这意味着您正在使用Apache / mod_wsgi,那么请注意mod_wsgi必须针对相同的Python版本/安装进行编译,并且您需要验证mod_wsgi是否在运行时获取相同的libpython.so,因为它是指示Python的mod_wsgi图书馆链接。
答案 1 :(得分:2)
[求助]感谢patrys和Graham Dumpleton,很明显我的自定义构建Python 2.7和wsgi安装错误,并且缺少关键库链接。 现在按照下面的说明解决了这个问题,解决了问题。 感谢所有聪明善良的人分享信息。
重新安装Python:https://askubuntu.com/questions/17841/will-python2-7-be-available-for-lucid-in-future
然后卸载WSGI:sudo apt-get purge libapache2-mod-wsgi
答案 2 :(得分:1)
此特定符号来自libpython*.*.so.1.0
(用您的python版本替换通配符)。您应该在使用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
您使用的是自定义版本吗?您的_psycopg.so
版本似乎根本没有与libpython
相关联。