Mac OS X Lion Psycopg2:找不到符号:_PQbackendPID [英] Mac OS X Lion Psycopg2: Symbol not found: _PQbackendPID

查看:376
本文介绍了Mac OS X Lion Psycopg2:找不到符号:_PQbackendPID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近升级到Mac OS X Lion,并试图使psycopg2再次与python 2.6一起使用.以前网站上的说明强制Python在32位以上运行(参见此处的地方:

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

推荐答案

最近遇到了尝试将psycopg2(2.8.2)导入python3(3.5.3)项目的问题.使用PostgreSQL 9.6 + pgAdmin3运行macOS Sierra(10.12.6).

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:在安装SQL程序和安装程序创建的动态链接

TLDR: be careful when installing SQL programs & the dynamic links that installers create

据我所知,与psycopg2(2.8.2)兼容的libpq动态库(libpq.5.dylib)是libpq 5.9+(libpq.5.9.dylib)

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)

在安装postgres(或其他与postgres相关的程序)后,它们可能会在/usr/lib中创建到新安装的.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.

例如,/usr/lib/libpq.5.dylib可能指向版本为5.6的./Applications/pgAdmin3.app/Contents/Frameworks/libpq.5.dylib;在这种情况下,较早版本的libpq动态库可能不包含某些功能,例如_PQsslAttribute.

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.

最适合我的解决方案:

$PATH中向上移动/usr/local/lib(因为usr/lib只能由root写入),然后在/usr/local/lib中创建动态链接,以指向/Library/PostgreSQL/9.6/lib/libpq.5.9.dylib,如下所示:

Move /usr/local/lib up in $PATH (since usr/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:

cd /usr/local/lib
ln -s /Library/PostgreSQL/9.6/lib/libpq.5.9.dylib ./libpq.5.dylib

这篇关于Mac OS X Lion Psycopg2:找不到符号:_PQbackendPID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆