Python 无法在mac上使用easy_Install或pip进行安装

Python 无法在mac上使用easy_Install或pip进行安装,python,lxml,pip,easy-install,pycrypto,Python,Lxml,Pip,Easy Install,Pycrypto,我正在尝试使用easy_install(和pip)安装lxml和pycrypto模块,但收到如下错误消息 Running lxml-2.3.4/setup.py -q bdist_egg --dist-dir /tmp/easy_install-kGsWMh/lxml-2.3.4/egg-dist-tmp-Gjqy3f Building lxml version 2.3.4. Building without Cython. Using build configuration of libxsl

我正在尝试使用easy_install(和pip)安装lxml和pycrypto模块,但收到如下错误消息

Running lxml-2.3.4/setup.py -q bdist_egg --dist-dir /tmp/easy_install-kGsWMh/lxml-2.3.4/egg-dist-tmp-Gjqy3f
Building lxml version 2.3.4.
Building without Cython.
Using build configuration of libxslt 1.1.24
In file included from /usr/include/limits.h:63,
                 from /Developer/usr/bin/../lib/gcc/powerpc-apple-darwin10/4.0.1/include/limits.h:10,
                 from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:19,
                 from src/lxml/lxml.etree.c:4:
/usr/include/sys/cdefs.h:540:4: error: #error Unknown architecture
In file included from /usr/include/limits.h:64,
                 from /Developer/usr/bin/../lib/gcc/powerpc-apple-darwin10/4.0.1/include/limits.h:10,
                 from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:19,
                 from src/lxml/lxml.etree.c:4:
/usr/include/machine/limits.h:10:2: error: #error architecture not supported
In file included from /usr/include/sys/_types.h:33,
                 from /usr/include/_types.h:27,
                 from /usr/include/stdio.h:67,
                 from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:33,
                 from src/lxml/lxml.etree.c:4:
/usr/include/machine/_types.h:36:2: error: #error architecture not supported
In file included from /usr/include/_types.h:27,
                 from /usr/include/stdio.h:67,
                 from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:33,
                 from src/lxml/lxml.etree.c:4:
/usr/include/sys/_types.h:94: error: syntax error before ‘__darwin_blkcnt_t’
    src/lxml/lxml.etree.c:165640: error: syntax error before ‘val’
    src/lxml/lxml.etree.c:165645: error: syntax error before ‘val’
布拉布拉

src/lxml/lxml.etree.c:165645: error: syntax error before ‘val’

lipo: can't figure out the architecture type of: /var/folders/f3/2q2x2p015kzgd4nbrn_qwykh0000gn/T//cc1pnrww.out

error: command 'gcc-4.0' failed with exit status 1
我在尝试安装pycrypto时也遇到了类似的语法错误。我试过了,但没有成功。我尝试使用setuptools-0.6c11-py2.6.egg和setuptools-0.6c11-py2.7.egg为python 2.6和2.7环境进行设置,但得到了相同的输出

我在网上搜索了很多,但找不到解决这个问题的方法

编辑:我使用macbook pro 2010上的OSX 10.7,并安装了XCode 4和3

在尝试上面链接中的命令时,我将args替换为最新版本

python setup.py build --static-deps --libxml2-version=2.7.8  --libxslt-version=1.1.26 
sudo python setup.py install
我在别的帖子上读到过,也试过这个

STATIC_DEPS=true sudo easy_install --allow-hosts=lxml.de,*.python.org lxml
解决方案:

正如@jdi建议的那样,我做了以下几点

$ brew install --use-llvm libxml2
$ brew install --use-llvm libxslt
从安装了gcc,因为我仍然面临建议的选项1和2的问题

那么这个

$ export ARCHFLAGS="-arch i386 -arch x86_64"
$ /usr/bin/python2.6 setup.py build
$ sudo /usr/bin/python2.6 setup.py install
或者这个,会有用的

$ sudo env ARCHFLAGS="-arch i386 -arch x86_64" easy_install-2.6 lxml

pycrypto也同样适用于

这表明您的构建不正确:
/Developer/usr/bin//lib/gcc/powerpc-apple-darwin10
,当然,除非您使用的是旧的powerpc机器

检查正在运行的OSX版本,以及用于构建lxml的命令。在构建之前,您可能需要在shell中设置
export ARCHFLAGS=“-arch i386-arch x86_64”
,以避免使用
ppc
构建。不知道你为什么会有一个老拱门

另外,请确保安装了最新的Xcode。而且,如果你在逐字逐句地关注你发布的链接,请确保你使用的是这些软件包的最新版本,而不是文字版本,因为该链接已经存在3年了

如果所有其他操作都失败,请安装并通过该软件包管理器进行安装

更新:在XCode 4.2+更新后缺少GCC 4.2的选项

挑一个

  • 使用以下简单指南安装gcc 4.2:

  • 使用自制软件进行安装:

    brew点击自制/复制

    brew安装自制/dupes/apple-gcc42

  • 完全忽略gcc,在brew中使用llvm

    brew安装--使用llvm libxml2


  • 我已经更新了帖子来回答你的问题。我仍然不确定为什么easy\u install不起作用,因为如果我使用easy\u install,理想情况下我不需要配置任何东西right@rajivvishwa:删除xcode 3,并确保将xcode 4更新为最新版本。如果它试图构建ppc,那么显然存在架构问题。另外,确保在最新的xcode4中进入prefs并让它安装命令行工具。我打赌你没有更新命令行工具,它仍然使用xcode 3工具构建。正如我建议的那样,我完全删除了xcode 3,并从apple下载中安装了最新的命令行工具(xcode 4说它已经安装)。但是现在有一个新问题,我不再有gcc-4.2:(这就是我在easy_install时看到的,
    无法执行/usr/bin/gcc-4.2:没有这样的文件或目录错误:命令“/usr/bin/gcc-4.2”失败,退出状态为1
    我在谷歌上搜索,发现Lion/XCode 4.2+不支持gcc-4.2!现在怎么办?@rajivvishwa:查看更新以了解如何处理。3选项。你完全正确但是现在是路径,因为它试图用正确的版本编译。我遵循了你的步骤,它成功了。我已经更新了帖子。谢谢!