无法使用 XCode4 在 OSX 10.6.7 上安装 psycopg2

发布于 2024-10-25 17:11:11 字数 1509 浏览 1 评论 0原文

尝试在 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

有谁知道我该怎么做才能安装它? 我已经安装了 Postgres,它似乎工作正常。

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

Trying to install psycopg2 on OSX results in the following:

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

Does anyone have any idea what can I do to get it installed?
I have Postgres installed and it seems to work fine.

I’ve tried both easy_install and pip install, but both end up with a similar message.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤凫 2024-11-01 17:11:11

似乎 ARCHFLAGS 实际上粘贴有问题,所以最后使用:

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

实际上有效。

It seems that there was something wrong with the ARCHFLAGS actually sticking, so finally using:

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

actually worked.

握住你手 2024-11-01 17:11:11

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

  • 在运行 pyscopg2 的 setup.py 脚本时覆盖拱门(正如 Adam 指出的那样,Distutils ARCHFLAGS 就是实现这一点的方法)
  • 返回使用Xcode 3(或者尝试一些不受支持的 hacks 以将 Xcode 3 与 Xcode 4 一起安装)
  • 尝试使用不同的 Python。例如,对于 Python 2.7,python.org 提供了 i386/x86_64 Python 的安装程序此处
  • 或者您可以使用第三方包管理器构建和安装所需的所有内容,例如 MacPorts

    sudo port install py27-psycopg2 # 安装 Python2.7、portgresql 和 pysycopg2
    

The problem is that the Python 2.6 included with OS X 10.6 was built for three supported architectures (i386, x86_64, and ppc for compatibility with earlier releases of OS X) and Python's Distutils tries to ensure that all C extension modules are built with the same archs as the Python interpreter and library. But Xcode 4 has apparently removed support for PPC. Until an official patch is available, you can either:

  • override the archs when running the setup.py script for pyscopg2 (as Adam points out, the Distutils ARCHFLAGS is the way to do that)
  • go back to using Xcode 3 (or try some unsupported hacks for installing Xcode 3 along side of Xcode 4)
  • try using a different Python. For instance, for Python 2.7, python.org provides an installer for an i386/x86_64 Python here
  • or you could build and install everything you need using a third-party package manager, like MacPorts.

    sudo port install py27-psycopg2 # installs Python2.7, portgresql, and pysycopg2
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文