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已經返回,並且我將耗盡資源來解決問題。