pip安装问题numpy – RuntimeError:破损的工具链:无法链接一个简单的C程序
我试图安装numpy(和scipy和matplotlib)到virturalenv。
我不断收到这些错误:
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
虽然这很丑,但看起来还是有效的
sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install --upgrade numpy
请注意,如果在numpy以外的其他程序包中收到此错误(例如lxml),请在commnd结尾处指定该包名称而不是numpy
。
我看到了一个与安装gem有关的问题
Ruby Gem安装Json在Mavericks和Xcode 5.1上失败 – 未知参数:'-multiply_definedsuppress'
这只是一个临时的解决scheme,在某些时候,编译器选项将不得不被修复
问题是你无法编译。
首先,确保您已经接受Xcode的新条款和条件。 要做到这一点,只需打开xCode并接受。
然后,尝试安装gcc
brew install gcc
最后,尝试安装Numpy
pip install numpy
希望这可以帮助。
如果你不想使用sudo(所以在使用venv的时候保留了权限和类似的东西),你可以把ARCHFLAGS声明添加到你的.bash_profile中,并且像平常一样运行。 这与小牛和Xcode 5.1一起使用venv:
在〜/ .bash_profile中:
export ARCHFLAGS = -Wno-error = unused-command-line-argument-hard-error-in-future
然后,只需运行命令:
pip安装 – 升级numpy
我只需要打开XCode并接受协议并让它安装这些工具。 然后我回到PyCharm,再次安装了numpy,没有任何问题。
在某些情况下,在OS X升级XCode后,XCode将要求用户(具有pipe理权限)接受新的许可证。 在许可证被接受之前,clang和gcc在尝试编译和链接代码时会发出错误。 或者至less是python包。
如果启动XCode并接受许可证,则错误不再显示。
至less,这是我的情况。
对于有类似问题的fedora用户,请尝试安装这些包:
(如果不使用python3,则使用python-devel和pip来代替pip3)
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
如果你正在运行一个linux发行版,你可能需要一个C编译器,特别是如果你看到如sh: gcc: command not found
这样的警告行。 您可以按照下面的说明进行操作:
-
Fedora,Red Hat,CentOS或Scientific Linux
# yum groupinstall 'Development Tools'
-
Debian或Ubuntu Linux
$ sudo apt-get update $ sudo apt-get install build-essential manpages-dev
然后你可以尝试重新运行:
sudo pip install numpy
上面的工作只有在安装python3-dev之后。
这意味着它找不到你的C编译器。 如果连接其他编译器失败,请尝试安装gcc编译器。
在Fedora 22上,通过更新pip本身来解决这个问题: sudo pip install --upgrade pip