在Mac OS X上安装Python的Pandas出现错误

6
我想安装Pandas用于Python。
我已经安装了最新的Xcode、命令行工具、pip和easy_install,但是安装时一直出现以下错误。有人可以帮忙吗?
sudo easy_install pandas

> Best match: pandas 0.13.1
>Downloading https://pypi.python.org/packages/source/p/pandas/pandas-0.13.1.zip#md5=50e4902238dd5312c20c1c85fb024bb6
>Processing pandas-0.13.1.zip
>Running pandas-0.13.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-oU7Yfm/pandas-0.13.1/egg-dist-tmp-I4Mw_P
>warning: no files found matching 'README.rst'  no previously-included directories found matching 'doc/build'
>warning: no previously-included files matching '*.so' found anywhere in distribution
>warning: no previously-included files matching '*.pyd' found anywhere in distribution
>warning: no previously-included files matching '*.pyc' found anywhere in distribution
>warning: no previously-included files matching '.git*' found anywhere in distribution
>warning: no previously-included files matching '.DS_Store' found anywhere in distribution
>warning: no previously-included files matching '*.png' found anywhere in distribution
>clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
>clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
>error: Setup script exited with error: command 'cc' failed with exit status 1

安装XCode的命令行工具 - Emin Mastizada
安装Python的某些东西,我建议使用pip install <package>。例如:'sudo pip install pandas'。 - Emin Mastizada
这是由Xcode 5.1的更改和苹果对系统Python的构建选项选择引起的问题。重复的https://dev59.com/MOo6XIcBkEYKwwoYKQ_G。 - Ned Deily
@EminMastizada 已安装了XCode命令行工具的最新版本。 - kevin
@NedDeily 很不幸,这些解决方案都不适用于pandas。所以我想这个问题仍然有效。请不要关闭。请求更多建议。 - kevin
我强烈推荐使用Anaconda,它可以避免这些痛苦的构建问题,而且您也不需要使用sudo。 - Andy Hayden
1个回答

9
正如评论中所指出的,这是由Xcode 5.1的更改和苹果对系统Python 2.7的构建选项选择所导致的常见问题。您可以按照这里建议的方法解决此问题,即删除有问题的选项。如果您需要使用sudo(如果您使用系统提供的easy_install可能需要),还需要确保您在sudo环境中定义变量。一种方法是:
sudo bash
umask 022
export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments
/usr/bin/easy_install pandas
exit

除了使用 sudo,还有其他选项可用,比如使用virtualenv或者使用pip install --user pandas

更新[2014-05-16]:预计的是,Apple已经在OS X 10.9.3中更新了系统Python(2.7、2.6和2.5),因此当使用最新的Mavericks和Xcode 5.1+时,不再需要这个解决方法。然而,目前来看,在使用Xcode 5.1+OS X 10.8.x(Mountain Lion,目前为10.8.5)仍需要使用这个解决方法。


很好。如果你得到了一个你提出的SO问题的答案,请将其标记为已接受或编辑问题,直到你得到一个可以接受的答案。这样,你和回答者都会得到认可,并且在寻找要回答的问题时节省其他人的时间。 - Ned Deily

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接