2012-05-18 36 views
1

我试图安装使用的easy_install(画中画)LXML和pycrypto模块,但收到错误消息用的easy_install或PIP安装像无法在Mac

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时,出现类似的语法错误。我试过this answer但徒劳无功。我尝试使用setuptools-0.6c11-py2.6.egg和setuptools-0.6c11-py2.7.egg设置python 2.6和2.7环境,但得到相同的输出。

我在网上搜索了很多,但无法找到解决方案。

编辑:我在OSX 10.7上的MacBook Pro 2010,并有4的XCode和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从因为我仍然面临着机智的问题-h选项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以及

回答

2

这里这个权利是指示你正在错误地构建它:/Developer/usr/bin/../lib/gcc/powerpc-apple-darwin10,除非你使用的是旧的powerpc机器。

检查OSX版本正在运行,并且使用的是建立lxml的命令。有可能你需要在构建之前在你的shell中设置export ARCHFLAGS="-arch i386 -arch x86_64",以避免它用ppc构建。不知道为什么你会得到一个旧的拱门。

此外,请确保您已安装最新的Xcode。而且,如果您是按照您发布的链接逐字发布的,请确保您使用的是这些软件包的最新版本,而不是该链接的文字版本为3岁。

如果一切都失败了,安装homebrew并通过包管理器进行安装。

更新: XCode 4后缺少GCC 4.2的选项。2+更新

选择一个

  1. 使用这个简单的指南安装gcc 4.2:
    http://caiustheory.com/install-gcc-421-apple-build-56663-with-xcode-42

  2. 使用自制软件进行安装:

    brew tap homebrew/dupes
    brew install homebrew/dupes/apple-gcc42

  3. 完全忽略gcc和使用LLVM与酿造

    brew install --use-llvm libxml2

+0

我已经更新后为您解答。我仍然不确定为什么easy_install不起作用,理想情况下,如果我使用easy_install,我不需要配置任何东西 – rajivvishwa

+0

@rajivvishwa:删除xcode 3,并确保xcode 4更新到最新版本。如果它试图构建ppc,你显然会遇到体系结构问题。另外,请确保在最新的xcode4中进入prefs并安装命令行工具。我敢打赌,你没有更新命令行工具和它的仍然建设与xcode 3工具。 – jdi

+0

正如所建议的,我完全删除了Xcode 3,并安装了苹果下载的最新命令行工具(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