在 OS X 10.7 Lion 上安装 pycurl
我正在尝试在本地环境中安装 PyCurl,该环境在 OS X 10.7 Lion 上有 python 2.7 和 gcc-4.2。我尝试根据这个答案来执行此操作 安装 PyCurl 时出错:
sudo env ARCHFLAGS="-arch x86_64" pip install pycurl
这失败了,因为我有 gcc-4.2通过 Xcode 安装:
error: command 'gcc-4.0' failed with exit status 1
我还尝试下载源代码并构建 setup.py (我根据 尝试在 Mac Snow Leopard 上安装 PyCurl 时出现问题):
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -pipe -DHAVE_CURL_SSL=1 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/pycurl.c
这会导致与上面相同的错误。我已经验证我确实有 gcc-4.2 并且它链接到我的 /usr/bin。
我认为如果我正确编译它,它就会工作,这样它就知道在安装时使用 gcc-4.2 而不是 gcc-4.0。但是,我不知道如何执行此操作,也没有找到一些内容来解释传递参数以使用特定的 gcc。如果可能的话,我想避免覆盖系统默认值。
I'm trying to install PyCurl in my local environment which has python 2.7 and gcc-4.2 on OS X 10.7 Lion. I've tried doing this based on this answer Error installing PyCurl:
sudo env ARCHFLAGS="-arch x86_64" pip install pycurl
Which fails because I have gcc-4.2 installed via Xcode:
error: command 'gcc-4.0' failed with exit status 1
I've also tried downloading the source and building a setup.py (I modified this based on Problem trying to install PyCurl on Mac Snow Leopard):
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -pipe -DHAVE_CURL_SSL=1 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/pycurl.c
This results in the same error as above. I have verified that I do indeed have gcc-4.2 and that it is linked to my /usr/bin.
I'm thinking that it will work if I compile it correctly so that it knows to use gcc-4.2 when installing instead of gcc-4.0. However, I don't know how to do this and have not found something to explain passing an argument to use a particular gcc. I want to avoid overriding system defaults if possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的系统上可能安装了仅 32 位的 Python 2.7(可能从 python.org 下载),它是使用
gcc-4.0
构建的,并包含 PPC 通用变体。安装了 Xcode 4(10.7 的默认设置,10.6 的可选)时,使用这些 Python 构建 C 扩展模块会出现很大问题,因为 gcc-4.0 和 PPC 支持均已被删除。最简单、最好的长期解决方案是安装 64 位/32 位 Python 版本(请参阅 python. org 下载页面 当前版本)或在 10.7 中使用 Apple 提供的 Python 2.7.1 (/usr/bin/python2.7
)。Chances are you have a 32-bit-only Python 2.7 installed on your system (possibly downloaded from python.org) which was built with
gcc-4.0
and includes a PPC universal variant. Building C extension modules with these Pythons is very problematic with Xcode 4 installed (the default for 10.7 and optional for 10.6) becausegcc-4.0
and PPC support have both been removed. The easiest and best long-term solution is to install a 64-bit/32-bit Python build (see the python.org download page for current releases) or simply use the Apple-supplied Python 2.7.1 (/usr/bin/python2.7
) in 10.7.