Python 无法在带有XCode4的OSX 10.6.7上安装psycopg2

Python 无法在带有XCode4的OSX 10.6.7上安装psycopg2,python,installation,xcode4,psycopg2,pip,Python,Installation,Xcode4,Psycopg2,Pip,尝试在OSX上安装psycopg2会导致以下结果: building 'psycopg2._psycopg' extension creating build/temp.macosx-10.6-universal-2.6 creating build/temp.macosx-10.6-universal-2.6/psycopg gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -W

尝试在OSX上安装psycopg2会导致以下结果:

building 'psycopg2._psycopg' extension

creating build/temp.macosx-10.6-universal-2.6

creating build/temp.macosx-10.6-universal-2.6/psycopg

gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch ppc -arch x86_64 -pipe -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090003 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -I. -I/usr/local/Cellar/postgresql/9.0.3/include -I/usr/local/Cellar/postgresql/9.0.3/include/server -c psycopg/psycopgmodule.c -o build/temp.macosx-10.6-universal-2.6/psycopg/psycopgmodule.o

/usr/libexec/gcc/powerpc-apple-darwin10/4.2.1/as: assembler (/usr/bin/../libexec/gcc/darwin/ppc/as or /usr/bin/../local/libexec/gcc/darwin/ppc/as) for architecture ppc not installed

Installed assemblers are:

/usr/bin/../libexec/gcc/darwin/x86_64/as for architecture x86_64

/usr/bin/../libexec/gcc/darwin/i386/as for architecture i386

psycopg/psycopgmodule.c:1009: fatal error: error writing to -: Broken pipe

compilation terminated.

lipo: can't open input file: /var/folders/zf/zfsYTD29GwSWm+UDcF6VxE+++TM/-Tmp-//ccd8ckcV.out (No such file or directory)

error: command 'gcc-4.2' failed with exit status 1
有人知道我能做些什么来安装它吗? 我安装了博士后,它似乎工作得很好


我尝试过easy_install和pip install,但最终都得到了类似的消息。

问题是,OS X 10.6中包含的Python 2.6是为三种受支持的体系结构而构建的(i386、x86_64和ppc,用于与早期版本的OS X兼容)Python的Distutils试图确保所有C扩展模块都使用与Python解释器和库相同的
arch
s构建。但Xcode 4显然已经取消了对PPC的支持。在正式补丁可用之前,您可以:

  • 在运行pyscopg2的setup.py脚本时重写archs(正如Adam所指出的,Distutils
    ARCHFLAGS
    就是这样做的方法)
  • 回到使用Xcode 3(或者尝试一些不受支持的方法,沿着Xcode 4安装Xcode 3)
  • 尝试使用不同的Python。例如,对于Python2.7,Python.org提供了i386/x86_64 Python的安装程序
  • 或者,您可以使用第三方软件包管理器构建和安装所需的一切,如


看起来拱形标志实际粘贴有问题,所以最后使用:

sudo env ARCHFLAGS=“-arch i386-arch x86_64”pip安装psycopg2


实际上有效。

也有同样的问题,这确实有效!请把它标为答案。
sudo port install py27-psycopg2 # installs Python2.7, portgresql, and pysycopg2