Python 2.7 Psycopg2正在安装,Python无法读取-OS 10.8.4、Python 2.7、PostgreSQL 9.2

Python 2.7 Psycopg2正在安装,Python无法读取-OS 10.8.4、Python 2.7、PostgreSQL 9.2,python-2.7,osx-mountain-lion,psycopg2,postgresql-9.2,Python 2.7,Osx Mountain Lion,Psycopg2,Postgresql 9.2,操作系统10.8.4、Python 2.7、PostgreSQL 9.2 在过去的10多个小时里,我一直在尝试为Django安装Psycopg2,现在我收到了谷歌似乎无法帮助我解决的警告和故障: 在清理了所有现有的Psycopg2和PostgreSQL文件,重新安装了PostgreSQL 9.2和Python 2.7之后,我在尝试使用Pip安装Psycopg2时仍然遇到了_PQbackendPID错误。因此,我尝试在安装时更改ARCHFLAGS设置: $ sudo env ARCHFLAGS="

操作系统10.8.4、Python 2.7、PostgreSQL 9.2

在过去的10多个小时里,我一直在尝试为Django安装Psycopg2,现在我收到了谷歌似乎无法帮助我解决的警告和故障:

在清理了所有现有的Psycopg2和PostgreSQL文件,重新安装了PostgreSQL 9.2和Python 2.7之后,我在尝试使用Pip安装Psycopg2时仍然遇到了_PQbackendPID错误。因此,我尝试在安装时更改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);
./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);
这是:

 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);
./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);
(最后一条消息出现在索引1-6中)

这是:

 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);
./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);
这是:

 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);
./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
~/$python2.7
Python 2.7.5(v2.7.5:AB05E7DD27882013年5月13日13:18:45)
[GCC 4.2.1(苹果公司建造5666)(dot 3)]关于达尔文
有关详细信息,请键入“帮助”、“版权”、“信用证”或“许可证”。
>>>导入psycopg
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
ImportError:没有名为psycopg的模块
>>>导入psycopg2
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
文件“/Library/Python/2.7/site-packages/psycopg2/_-init___;u.py”,第50行,在
从psycopg2.\u psycopg导入二进制、数字、字符串、日期时间、ROWID
ImportError:dlopen(/Library/Python/2.7/site-packages/psycopg2//\u psycopg.so,2):未找到符号:\u PQbackendPID
引用自:/Library/Python/2.7/site-packages/psycopg2//u psycopg.so
应为:平面命名空间
在/Library/Python/2.7/site-packages/psycopg2//u psycopg.so中

我们的老朋友_PQbackendPID回来了,我没有资源来解决这个问题。

在我看来,
libpq
。因此与编译时使用的
libpq
不一样

检查您的
DYLIB\u库\u路径
。还可以使用
install\u name\u工具
查看
\u psycopg.so
是否具有指向
libpq.dylib的
@相对路径
、非限定路径或绝对路径