无法在Mac上使用easy_install或pip安装 [英] Unable to Install with easy_install or pip on mac

查看:886
本文介绍了无法在Mac上使用easy_install或pip安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to install lxml and pycrypto modules using easy_install (and pip) but getting error messages like

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. .

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时,我也收到类似的语法错误.我尝试了此答案,但没有成功.我尝试使用setuptools-0.6c11-py2.6.egg和setuptools-0.6c11-py2.7.egg为python 2.6和2.7环境设置,但得到相同的输出.

I'm getting similar syntax errors when I try to install pycrypto as well. I tried this answer but in vain. I tried setting up for python 2.6 and 2.7 environments using setuptools-0.6c11-py2.6.egg and setuptools-0.6c11-py2.7.egg but getting the same output.

我在网上进行了很多搜索,但是找不到解决方案.

I searched a lot online but cant find solution for this.

编辑:我在Macbook Pro 2010上的OSX 10.7上,并安装了XCode 4和3.

I'm on OSX 10.7 on macbook pro 2010, and have XCode 4 and 3 installed

尝试上面链接中的命令时,我会用最新版本替换args.

I'd args with replaced with the latest version while trying the commands in the link above.

python setup.py build --static-deps --libxml2-version=2.7.8  --libxslt-version=1.1.26 
sudo python setup.py install

我在另一篇文章中读过,也尝试过

I read on someother post and tried this as well

STATIC_DEPS=true sudo easy_install --allow-hosts=lxml.de,*.python.org lxml

解决方案:

按照@jdi的建议,我做了以下

As @jdi suggested I did the following

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

链接安装了gcc,因为我仍然遇到选项1和2条建议

Installed gcc from link, since I was still facing issues with option 1 and 2 suggested

然后,这个

$ 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也同样使用

Same worked for pycrypto as well

推荐答案

在这里,这表明您正在错误地构建它:/Developer/usr/bin/../lib/gcc/powerpc-apple-darwin10,除非您当然是在旧的PowerPC机器上.

This right here is an indication that you are building it improperly: /Developer/usr/bin/../lib/gcc/powerpc-apple-darwin10, unless of course you are on an old powerpc machine.

检查正在运行的OSX的版本,以及用于构建lxml的命令.您可能需要在构建之前在外壳中设置export ARCHFLAGS="-arch i386 -arch x86_64",以避免使用ppc进行构建.不确定为什么要使用旧拱门.

Check the version of OSX you are running, and the commands you are using to build lxml. Chances are you might need to set export ARCHFLAGS="-arch i386 -arch x86_64" in your shell before building, in order to avoid it building with ppc. Not sure why you are getting an old arch.

此外,请确保您安装了最新的Xcode.而且,如果您要逐字关注发布的链接,请确保您使用的是这些软件包的最新版本,而不是文字版本,因为该链接已有3年的历史.

Also, make sure you have the latest Xcode installed. And, if you are following that link you posted, word for word, make sure you are using the most recent versions of those packages and not the literal versions as that link is 3 years old.

如果其他所有方法均失败,则安装 homebrew 并通过该软件包管理器进行安装.

If all else fails, install homebrew and install it through that package manager.

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

Update: Options for lack of GCC 4.2 after XCode 4.2+ update

选择一个

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

  1. Install gcc 4.2 using this simple guide:
    http://caiustheory.com/install-gcc-421-apple-build-56663-with-xcode-42

使用自制软件安装它:

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

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

Completely ignore gcc and use llvm with brew

brew install --use-llvm libxml2

这篇关于无法在Mac上使用easy_install或pip安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆