本文介绍了Psycopg2安装,Python无法读取-OS 10.8.4,Python 2.7,PostgreSQL 9.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OS 10.8.4,Python 2.7,PostgreSQL 9.2

OS 10.8.4, Python 2.7, PostgreSQL 9.2

过去10多个小时我一直在为Django安装Psycopg2,现在正收到警告以及Google似乎无法帮助我的失败:

I've been spending the past 10+ hours trying to get Psycopg2 installed for Django and am now receiving warnings and a failure that Google can't seem to help me with:

在清除所有现有的Psycopg2& PostgreSQL文件,重新安装PostgreSQL 9.2和Python 2.7,尝试通过Pip安装Psycopg2时仍然出现_PQbackendPID错误。因此,我尝试在安装时更改ARCHFLAGS设置:

After cleaning out all existing Psycopg2 & PostgreSQL files, reinstalling PostgreSQL 9.2 and Python 2.7, I was still getting the _PQbackendPID error when trying to install Psycopg2 with Pip. So I tried changing the ARCHFLAGS setting on install:

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

并收到多次重复出现的错误和警告:

And received several errors and warnings repeated over:

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);

(最后一条出现在索引1-6的消息)

(that last message appeared for indexes 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时:

HOWEVER, when I move into 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已经返回,我的资源不足以解决问题

And our old friend _PQbackendPID has returned and I'm running out of resources to problem solve.

推荐答案

在我看来, libpq 链接到 _psycopg.so 在运行时与 libpq 所针对的编译器不同。

It looks to me like the libpq being linked to at runtime by _psycopg.so isn't the same as the libpq that was compiled against.

检查您的 DYLIB_LIBRARY_PATH 。还可以使用 install_name_tool 查看 _psycopg.so 是否具有 @relative libpq.dylib 的绝对路径或绝对路径。

Check your DYLIB_LIBRARY_PATH. Also use the install_name_tool to see whether _psycopg.so has an @relative, unqualified or absolute path to libpq.dylib.

这篇关于Psycopg2安装,Python无法读取-OS 10.8.4,Python 2.7,PostgreSQL 9.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-16 07:39
查看更多