首页 文章

无法使用easy_install或pip在mac上安装

提问于
浏览
1

我正在尝试使用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’

bla bla . . .

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环境,但获得相同的输出 .

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

EDIT: 我在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

Solution:

正如@jdi建议我做了以下事情

$ brew install --use-llvm libxml2
$ brew install --use-llvm libxslt

link安装了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

1 回答

  • 2

    这是正确的,表明你正在不正确地构建它: /Developer/usr/bin/../lib/gcc/powerpc-apple-darwin10 ,除非你在旧的powerpc机器上 .

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

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

    如果所有其他方法都失败了,请安装homebrew并通过该软件包管理器安装它 .

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

    选一个

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

    • 完全忽略gcc并将llvm与brew一起使用

    brew install --use-llvm libxml2

相关问题