红帽上的 Python 和 Postgres

发布于 2024-09-28 22:53:16 字数 1024 浏览 4 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

十秒萌定你 2024-10-05 22:53:16

Red hat 附带了一个 postgres 版本,它可能与自定义安装发生冲突。 Python 使用 pg_config 来配置 psycopg2 构建。我将 postgres 安装到 /usr/local/pgsql/ 中,但调用 which pg_config 返回 /usr/bin/pg_config/

在psycopg2构建目录中,有一个文件setup.cfg,它可以让你显式定义pg_config的路径:

pg_config=/usr/local/pgsql/bin/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 calling which 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 to pg_config:

pg_config=/usr/local/pgsql/bin/pg_config

Setting this one parameter and re-compiling solved my problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文