2014-03-13 39 views
59

我试图安装numpy(和scipy和matplotlib)到virturalenv。PIP安装numpy的问题 - RuntimeError:损坏的工具链:无法链接一个简单的C程序

我不断收到这些错误,但:

RuntimeError: Broken toolchain: cannot link a simple C program 

---------------------------------------- 
Cleaning up... 
Command python setup.py egg_info failed with error code 1 

我有Xcode中的命令行工具安装

$ which gcc 
/usr/bin/gcc 
$ which cc 
/usr/bin/cc 

我在Mac OSX 10.9 使用BREW Python安装

编辑
是的,试图用pip安装。
整个回溯是巨大的(> 400线)

这里是它的一个部分:

C compiler: cc -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 -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe 



compile options: '-Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c' 

cc: _configtest.c 

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 

failure. 

removing: _configtest.c _configtest.o 

Traceback (most recent call last): 

    File "<string>", line 17, in <module> 

    File "/Users/bdhammel/Documents/research_programming/julia_env/build/numpy/setup.py", line 192, in <module> 

    setup_package() 

    File "/Users/bdhammel/Documents/research_programming/julia_env/build/numpy/setup.py", line 185, in setup_package 

    configuration=configuration) 

    File "/Users/bdhammel/Documents/research_programming/julia_env/build/numpy/numpy/distutils/core.py", line 169, in setup 

    return old_setup(**new_attr) 

    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup 

    dist.run_commands() 

    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands 

    self.run_command(cmd) 

    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command 

    cmd_obj.run() 

    File "/Users/bdhammel/Documents/research_programming/julia_env/build/numpy/numpy/distutils/command/egg_info.py", line 10, in run 

    self.run_command("build_src") 

    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command 

    self.distribution.run_command(command) 

    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command 

    cmd_obj.run() 

    File "/Users/bdhammel/Documents/research_programming/julia_env/build/numpy/numpy/distutils/command/build_src.py", line 153, in run 

    self.build_sources() 

    File "/Users/bdhammel/Documents/research_programming/julia_env/build/numpy/numpy/distutils/command/build_src.py", line 164, in build_sources 

    self.build_library_sources(*libname_info) 

    File "/Users/bdhammel/Documents/research_programming/julia_env/build/numpy/numpy/distutils/command/build_src.py", line 299, in build_library_sources 

    sources = self.generate_sources(sources, (lib_name, build_info)) 

    File "/Users/bdhammel/Documents/research_programming/julia_env/build/numpy/numpy/distutils/command/build_src.py", line 386, in generate_sources 

    source = func(extension, build_dir) 

    File "numpy/core/setup.py", line 674, in get_mathlib_info 

    raise RuntimeError("Broken toolchain: cannot link a simple C program") 

RuntimeError: Broken toolchain: cannot link a simple C program 
+0

请在'RuntimeError'行之上显示几行,以便我们看到哪些命令失败。另外,你是通过'pip'安装还是通过直接构建源代码? – MattDMo

+0

罗杰,现在编辑 – Ben

回答

68

虽然这是丑陋的,它似乎工作

sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install --upgrade numpy 

请注意,如果你是为numpy以外的其他程序包(如lxml)获取此错误时,请在通信结束时指定该程序包名称,而不是numpy

我看到了类似的问题,有人用安装宝石

Ruby Gem install Json fails on Mavericks and Xcode 5.1 - unknown argument: '-multiply_definedsuppress'

这只是一个临时的解决办法,在某些时候具有编译器选项必须是固定

+1

@本:FWIW,我有同样的问题(不使用brew)。它在将Xcode更新到5.1后出现。然而丑陋的,这似乎是(现在)的答案。 – orome

+0

它在这里工作。有谁知道这个问题的原因? – Trein

+2

[XCode 5.1发行说明]中有一个解释(https://developer.apple.com/library/ios/releasenotes/developertools/rn-xcode/xc5_release_notes/xc5_release_notes.html#//apple_ref/doc/uid/ TP40001051-CH2-SW12)。 – badzil

9

如果你不不想使用sudo(所以在使用venv时会保留权限和类似的东西),您可以将ARCHFLAGS声明添加到.bash_profile中,然后像平常一样运行。这为我工作与小牛的Xcode 5.1 VENV使用:

在〜/ .bash_profile中:

export ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future

然后,只需运行命令:

pip install --upgrade numpy

+4

上面的'sudo'用于系统范围的安装,可以在virtualenv –

0

以上只是为我工作安装python3-dev后。

13

问题是你无法编译。

首先,确保您已接受Xcode的新条款和条件。要做到这一点,只需打开xCode并接受。

然后,尝试与

brew install gcc 

最后安装GCC,尝试与

pip install numpy 

希望这有助于安装NumPy的。

+0

下运行,这对我很有用。问题是我没有打开xcode并接受条款和条件。 – Stephens

5

我只需打开XCode并接受协议并让它安装工具即可。然后我又回到PyCharm,再次安装numpy,没有任何问题。

2

在某些情况下,在OS X升级XCode之后,XCode将要求用户(具有管理权限)接受新的许可证。在许可证被接受之前,clang和gcc在尝试编译和链接代码时会发出错误。或者至少是python软件包。

如果启动XCode并接受许可证,则错误不再显示。

至少,这是我的情况。

0

这意味着它无法找到您的C编译器。 如果连接其他编译器失败,请尝试安装gcc编译器。

2

对于那些有类似的问题Fedora用户尝试安装这些packeges:

(如果不使用python3使用Python-devel的画中画,而不是PIP 3)

sudo dnf install python3-devel 
sudo dnf install make automake gcc gcc-c++ gcc-gfortran 
sudo dnf install redhat-rpm-config 
sudo dnf install subversion 

然后尝试

sudo pip3 install numpy 
1

如果你正在运行一个linux发行版,你可能需要一个C编译器,特别是如果你看到像sh: gcc: command not found这样的明显的日志行。您可以按照指示here,我已经总结如下:

  • Fedora的,红帽,CentOS的,或科学的Linux

    # yum groupinstall 'Development Tools'

  • Debian或者Ubuntu Linux操作系统

    $ sudo apt-get update $ sudo apt-get install build-essential manpages-dev

那么你可以尝试重新运行:

sudo pip install numpy 
0

在Fedora 22这是通过更新PIP自筹解决: sudo pip install --upgrade pip

0

对于泊坞(高山)和Python 3.X这个工作对我来说:

RUN apk add make automake gcc g++ subversion python3-dev