python - python安装scikit-learn的问题

标签 python pip scikit-learn

我正在尝试安装 python 包 scikit-learn。我一直收到错误消息。

我试过了

 pip install scikit­-learn

错误如下所示。我的安装有什么问题?

compile options: '-I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include -c'

c++: sklearn/svm/src/libsvm/libsvm_template.cpp

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

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: Command "c++ -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include -c sklearn/svm/src/libsvm/libsvm_template.cpp -o build/temp.macosx-10.9-intel-2.7/sklearn/svm/src/libsvm/libsvm_template.o" failed with exit status 1

----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/tmp/pip_build_root/scikit-learn/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-GYuqQN-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/tmp/pip_build_root/scikit-learn
Storing debug log for failure in /Users/johnkuk/Library/Logs/pip.log

我也尝试了几种不同的方式来安装这个包。从 easy_install,我还收到了以下错误消息。

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
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 "c++ -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include -c /private/tmp/easy_install-oD3dwa/scikit-learn-0.14.1/sklearn/svm/src/libsvm/libsvm_template.cpp -o build/temp.macosx-10.9-intel-2.7/private/tmp/easy_install-oD3dwa/scikit-learn-0.14.1/sklearn/svm/src/libsvm/libsvm_template.o" failed with exit status 1
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/distutils/misc_util.py:252: RuntimeWarning: Parent module 'numpy.distutils' not found while handling absolute import
  from numpy.distutils import log

最佳答案

我今天遇到了同样的麻烦,在尝试了很多方法之后,我在使用 pip 安装之前设置了一些环境变量为我解决了这个问题:

export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments

然后用sudo安装:

sudo -E pip install -U scikit-learn

这似乎是xcode更新的问题(对我来说是5.1.1),它不接受'-mno-fused-madd'作为参数,在它抛出警告之前,知道是错误,第一个两个命令忽略未使用的参数,因为它们是相同的并引发错误。

希望对您有所帮助,欢迎大家指正。

关于python - python安装scikit-learn的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22974521/

相关文章:

Python/Cython/C 和回调,使用 Cython 从 C 调用 Python 函数

python - Tkinter keyrelease 事件插入新行,而按键则不插入新行

python - 为什么 pip 不安装最新版本的包,即使 PyPI 上有更新版本?

python - Mysql客户端安装失败

python - Spacy 更新 msvc 未找到

python - 不平衡面板数据 : How to use Time Series Splits Cross-Validation?

python - 从 Google ml-engine (tensorflow) 中的存储桶中读取数据

python - 使用 NaN 按列对数据进行 Winsorizing

python - 如何在 scikit-learn 中使用随机 Logistic 回归找到最低的正则化参数 (C)?

python - scikit-learn pipeline (SVC) 的功能重要性