红帽上的 Python 和 Postgres
我在 Linux 上安装 psycopg2 时遇到问题。当我尝试导入 psycopg2 时收到以下错误。
Python 2.6.4 (r264:75706, Nov 19 2009, 14:52:22)
[GCC 3.4.6 20060404 (Red Hat 3.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/local/lib/python2.6/site-packages/psycopg2/__init__.py", line 69, in <module>
from _psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: /usr/local/lib/python2.6/site-packages/psycopg2/_psycopg.so: undefined symbol: PQserverVersion
我正在使用 Postgresql 9.0.1、Psycopg2 2.2.2、Python 2.6.4 和 RHEL 4。
这个问题与一年前的这个问题相同,但从未得到解答:http://code.activestate.com/lists/python-list/169772/。
有人见过这个错误吗?任何建议将不胜感激。
编辑:Postgresql 9.0.1、Psycopg2 2.2.2 和 Python 2.6.4 的相同组合在我的 mac(雪豹)上运行良好。所以我认为这个问题是红帽特有的。
I've been having trouble installing psycopg2 on linux. I receive the following error when I try to import psycopg2.
Python 2.6.4 (r264:75706, Nov 19 2009, 14:52:22)
[GCC 3.4.6 20060404 (Red Hat 3.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/local/lib/python2.6/site-packages/psycopg2/__init__.py", line 69, in <module>
from _psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: /usr/local/lib/python2.6/site-packages/psycopg2/_psycopg.so: undefined symbol: PQserverVersion
I'm using Postgresql 9.0.1, Psycopg2 2.2.2, Python 2.6.4, and RHEL 4.
The problem is identical to this question from a year ago, which was never answered: http://code.activestate.com/lists/python-list/169772/.
Has anyone seen this error? Any suggestions would be much appreciated.
EDIT: This same combination of Postgresql 9.0.1, Psycopg2 2.2.2, and Python 2.6.4 worked fine on my mac (snow leopard). So I expect the problem is something particular to Red Hat.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Red hat 附带了一个 postgres 版本,它可能与自定义安装发生冲突。 Python 使用 pg_config 来配置 psycopg2 构建。我将 postgres 安装到
/usr/local/pgsql/
中,但调用which pg_config
返回/usr/bin/pg_config/
。在psycopg2构建目录中,有一个文件
setup.cfg
,它可以让你显式定义pg_config
的路径:设置这个参数并重新编译解决了我的问题。
Red hat comes with a build of postgres, which can conflict with a custom installation. Python uses
pg_config
to configure the psycopg2 build. I installed postgres into/usr/local/pgsql/
, but callingwhich pg_config
returned/usr/bin/pg_config/
.In the psycopg2 build directory, there is a file
setup.cfg
, which lets you explicitly define the path topg_config
:Setting this one parameter and re-compiling solved my problem.