Mac OS X Lion Psycopg2:未找到符号:_PQbackendPID
我最近升级到 Mac OS X Lion,并试图让 psycopg2 再次与 python 2.6 一起工作。之前网站上强制 Python 在 32 位以上运行的说明(参见此处:http://favosdream.blogspot.com/2009/09/make-psycopg2-and-readline-work-in-snow.html )没有带来任何运气。即使尝试使用 arch -i386 python 强制 python 为 32 位,仍然会出现错误:
symbol not found: _PQbackendPID
Referenced from: /Library/Python/2.6/site-packages/psycopg2/_psycopg.so
Expected in: flat namespace
I recently upgraded to Mac OS X Lion and am trying to get psycopg2 working again with python 2.6. The instructions on previous sites to force Python to run in 32 bit more (seen places like here: http://favosdream.blogspot.com/2009/09/make-psycopg2-and-readline-work-in-snow.html ) aren't giving any luck. Even trying to force python to 32 bit using arch -i386 python is still giving me the error:
symbol not found: _PQbackendPID
Referenced from: /Library/Python/2.6/site-packages/psycopg2/_psycopg.so
Expected in: flat namespace
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
未找到符号:_PQbackendPID 预期位于:平面命名空间
我在使用 Big Sur 的 Arm64 Mac 上遇到了相同的符号错误。
我正在使用 Progressapp (x86_64) 和 psycopg2 v2.8.4 (Arm64)。由于 Progressapp Arm64 版本尚不可用,我决定检查 psycopg2 的库链接。
我的解决方案是,首先卸载Progressapp,
然后导出 PATH=/opt/local/lib/postgresql13/bin:$PATH 指向 Arm64 libpq.5.13.dylib,
最后重新安装Pogressapp。因此 psycopg2 加载所需的所有 Arm64 库。
Symbol not found: _PQbackendPID Expected in: flat namespace
I have come across the same symbol error on Arm64 Mac with Big Sur.
I am using Progressapp (x86_64) and psycopg2 v2.8.4 (Arm64). Since Progressapp Arm64 version is not yet available I decided to check the linking of the libraries for psycopg2.
My solution was, first to uninstall Progressapp,
then export PATH=/opt/local/lib/postgresql13/bin:$PATH point to Arm64 libpq.5.13.dylib,
and finally re-install Pogressapp. So psycopg2 loads all Arm64 libraries needed.
最近尝试将 psycopg2 (2.8.2) 导入 python3 (3.5.3) 项目时遇到此问题。使用 PostgreSQL 9.6 + pgAdmin3 运行 macOS Sierra (10.12.6)。
TLDR:安装 SQL 程序时要小心安装程序创建的动态链接
据我所知,与 psycopg2 (2.8.2) 兼容的所需 libpq 动态库 (
libpq.5.dylib
) 是 libpq 5.9+ (libpq.5.9.dylib
)当安装 postgres(或其他依赖 postgres 的程序)时,它们可能会在
/usr/lib
到新安装的 .dylib 文件,这些文件不一定是您想要的。例如,
/usr/lib/libpq.5.dylib
可能指向./Applications/pgAdmin3.app/Contents/Frameworks/libpq.5.dylib
,即5.6 版;在这种情况下,旧版本的 libpq 动态库可能不包含某些函数,例如_PQsslAttribute
。对我有用的解决方案:
将
/usr/local/lib
移至$PATH
中(因为usr/lib
> 只能由 root 写入),然后在/usr/local/lib
中创建一个动态链接以指向/Library/PostgreSQL/9.6/lib/libpq.5.9.dylib
代码>像这样:Recently had this issue trying to import psycopg2 (2.8.2) into a python3 (3.5.3) project. Running macOS Sierra (10.12.6), using PostgreSQL 9.6 + pgAdmin3.
TLDR: be careful when installing SQL programs & the dynamic links that installers create
From what I can tell, the required libpq dynamic library (
libpq.5.dylib
) that's compatible with psycopg2 (2.8.2) is libpq 5.9+ (libpq.5.9.dylib
)When postgres (or other postgres-dependent programs) are installed, they may create dynamic links in
/usr/lib
to the newly installed .dylib files, which may not necessarily be the ones you want.For example,
/usr/lib/libpq.5.dylib
may point to./Applications/pgAdmin3.app/Contents/Frameworks/libpq.5.dylib
, which is version 5.6; the older version of the libpq dynamic library may not include some functions, like_PQsslAttribute
, in this case.The solution that worked for me:
Move
/usr/local/lib
up in$PATH
(sinceusr/lib
may only be writable by root), then create a dynamic link in/usr/local/lib
to point to/Library/PostgreSQL/9.6/lib/libpq.5.9.dylib
like this:我在 Snow Leopard/10.6.8 上也遇到了这个问题,并且在一个相当紧张的合同中损失了半天时间。不好玩。我最终通过a)完全删除所有postgres版本并重新启动,b)完全删除我所有的psycopg2安装(使用locate并无情),c)将我的系统python升级到2.7,d)重新安装virtualenv和pip来修复它,所以他们指出在正确的 python 版本中,然后 e) 按照本页上的说明进行操作,从 dmg 安装程序安装 postgres 9.1 开始:
http://hardlifeofapo.com/psycopg2-and-postgresql-9- 1-on-snow-leopard/
最终就这么简单:
祝你好运!
I had this problem too on Snow Leopard/10.6.8, and just lost a half a day in the middle of a pretty intense contract. Not fun. I ended up fixing it by a) fully removing all postgres versions and rebooting, b) fully removing all my psycopg2 installs (use locate and be ruthless), c) upgrading my system python to 2.7, d) reinstalling virtualenv and pip so they pointed at the right python version, and then e) following the instructions on this page, starting with install postgres 9.1 from the dmg installer:
http://hardlifeofapo.com/psycopg2-and-postgresql-9-1-on-snow-leopard/
Ultimately it was this easy:
Good luck!
如果您在
/usr/bin/python2.6
中使用 Apple 提供的 Python 2.6,您是否尝试过arch -i386 python2.6
?但如果您仍在运行 32 位版本的 psycopg2 和 PostgreSQL 客户端库,那么可能是安装较新的 64 位或 64 位/32 位通用版本的好时机。 MacPorts 可以帮助解决这个问题。Did you try
arch -i386 python2.6
if you are using the Apple-supplied Python 2.6 in/usr/bin/python2.6
? But if you are still running a 32-bit version ofpsycopg2
and the PostgreSQL client libraries, it might be a good time to install newer 64-bit or 64-bit/32-bit universal versions. MacPorts can help with that.