2013-06-11 26 views
0

OS 10.8.4,Python 2.7版和PostgreSQL 9.2Psycopg2安装,不被Python的阅读 - OS 10.8.4,Python 2.7版和PostgreSQL 9.2

我已经花了近10个小时以上试图让Psycopg2安装Django的,我现在收到的警告和,谷歌似乎无法帮助我的失败:

清理所有现有Psycopg2 & PostgreSQL的文件,重新安装的PostgreSQL 9.2和Python 2.7之后,我仍然得到_PQbackendPID错误当试图用Pip安装Psycopg2时。所以,我试图改变ARCHFLAGS设置上安装:

$ sudo env ARCHFLAGS="-arch i386 -arch x86_64" pip install psycopg2 

并得到了几个错误和警告不断重复:

warning: no files found matching '*.py' under directory 'ZPsycopgDA' 
warning: no files found matching '*.gif' under directory 'ZPsycopgDA' 
warning: no files found matching '*.dtml' under directory 'ZPsycopgDA' 
warning: no files found matching '*' under directory 'psycopg2da' 
warning: no files found matching '*' under directory 'debian' 
no previously-included directories found matching 'doc/src/_build' 
warning: no files found matching 'ChangeLog' 

这:

clang: warning: argument unused during compilation: '-mno-fused-madd' 

这:

psycopg/pqpath.c:1177:17: warning: array index of '3' indexes past the end of an array (that contains 1 elements) [-Warray-bounds] PyTuple_SET_ITEM(dtitem, 3, tmp); 

(that最后一条消息出现了指标1-6)

这:

./psycopg/config.h:71:13: warning: unused function 'Dprintf' [-Wunused-function] 

这:

psycopg/diagnostics_type.c:64:54: warning: implicit conversion loses integer precision: 'Py_intptr_t' (aka 'long') to 'int' [-Wshorten-64-to-32] 
errortext = PQresultErrorField(self->err->pgres, (Py_intptr_t) closure); 

最后,我得到这个:

Successfully installed psycopg2 

然而,当我进入Python:

~/ $ python2.7 
Python 2.7.5 (v2.7.5:ab05e7dd2788, May 13 2013, 13:18:45) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import psycopg 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
ImportError: No module named psycopg 
>>> import psycopg2 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/Library/Python/2.7/site-packages/psycopg2/__init__.py", line 50, in <module> 
    from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID 
ImportError: dlopen(/Library/Python/2.7/site-packages/psycopg2/_psycopg.so, 2): Symbol not found: _PQbackendPID 
    Referenced from: /Library/Python/2.7/site-packages/psycopg2/_psycopg.so 
    Expected in: flat namespace 
in /Library/Python/2.7/site-packages/psycopg2/_psycopg.so 

而我们的老朋友_PQbackendPID已经返回,并且我将耗尽资源来解决问题。

回答

0

它看起来像libpq被链接到在运行时由_psycopg.so是不相同的编译为libpq

检查您的DYLIB_LIBRARY_PATH。也可以使用install_name_tool来查看_psycopg.so是否有@relative,不合格或绝对路径为libpq.dylib