Problems with pip install numpy - RuntimeError: Broken toolchain: cannot link a simple C program

89,495

Solution 1

While it's ugly, it appears to work

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

Note that if you are getting this error for a package other than numpy, (such as lxml) specify that package name instead of numpy at the end of the commnd.

I saw a similar issue someone was having with installing a gem

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

This is only a temporary fix, at some point the compiler options will have to be fixed

Solution 2

For Docker (Alpine) and Python 3.x this worked for me:

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

Solution 3

The problem is that you are unable to compile.

First, make sure that you have accepted the new Terms and Conditions with Xcode. To do this, just open up xCode and accept.

Then, try installing gcc with

brew install gcc

Finally, try to install Numpy with

pip install numpy

Hope this helps.

Solution 4

If you don't want to use sudo (so permissions and things like that are preserved when using venv), you can add the ARCHFLAGS declaration to your .bash_profile, and run as normal. This worked for me with Mavericks and Xcode 5.1 using with venv:

In ~/.bash_profile:

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

Then, just run the command:

pip install --upgrade numpy

Solution 5

If you are running a linux distribution, you may need a C compiler, especially if you see telltale log lines like sh: gcc: command not found. You can follow the instructions here, which I've summarized below:

  • Fedora, Red Hat, CentOS, or Scientific Linux

    # yum groupinstall 'Development Tools'

  • Debian or Ubuntu Linux

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

Then you can try rerunning:

sudo pip install numpy
Share:
89,495

Related videos on Youtube

Ben
Author by

Ben

Updated on July 08, 2022

Comments

  • Ben
    Ben almost 2 years

    I'm trying to install numpy (and scipy and matplotlib) into a virturalenv.

    I keep getting these errors though:

    RuntimeError: Broken toolchain: cannot link a simple C program
    
    ----------------------------------------
    Cleaning up...
    Command python setup.py egg_info failed with error code 1
    

    I have the command line tools for xcode installed

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

    I'm on Mac OSX 10.9 Using a brew installed python

    Edit
    Yes, trying to install with pip.
    The whole traceback is huge (>400 lines)

    Here is a section of it:

    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
    
    • MattDMo
      MattDMo about 10 years
      please show several of the lines above the RuntimeError line, so we can see which commands are failing. Also, are you installing via pip or by building the source directly?
    • Ben
      Ben about 10 years
      Rodger that, edited now
    • Cameron Hudson
      Cameron Hudson almost 4 years
      Lol @ "cannot link a simple C program". Such sass!
  • orome
    orome about 10 years
    @Ben: FWIW, I have the same issue (not using brew). It appeared after updating Xcode to 5.1. However ugly, this does appear to be the answer (for now).
  • Eren Güven
    Eren Güven about 10 years
    the sudo above is for system-wide installation, can run without in a virtualenv
  • badzil
    badzil about 10 years
    There is an explanation in the XCode 5.1 release notes.
  • orome
    orome over 9 years
    Is unused-command-line-argument-hard-error-in-future still needed with the latest Xcode under Yosemite? Things seem to work (at least for the packages I've tired) without it.
  • Stephens
    Stephens about 8 years
    this worked for me. Problem was I didn't open up xcode and accept terms and conditions.
  • xssChauhan
    xssChauhan over 5 years
    For anyone using docker python3 alpine image, this is the solution.
  • yair
    yair over 5 years
    I needed an apk update first, otherwise I got a ERROR: unsatisfiable constraints message.
  • Amorphous
    Amorphous over 5 years
    Thank you so much!
  • Eduard
    Eduard about 5 years
    This is also the solution for the docker python2 alpine image.
  • ThisGuyCantEven
    ThisGuyCantEven over 4 years
    I was able to do this on alpine with only gcc g++ make python3-dev for numpy/nmslib. The cause of this particular issue seems to be the missing c++ compiler g++ (it looks by the error that gcc and make are already installed). The other important parts of numpy build is the python3 headers which come with python3-dev.
  • Zack Plauché
    Zack Plauché over 3 years
    Anyone have a windows solution?
  • Felipe
    Felipe over 3 years
    For those running Big Sur Beta: (1) download and install Command Line Tools for Xcode 12.2 beta 3 (2) on terminal type sudo xcode-select --switch /Library/Developer/CommandLineTools (3) brew install gcc (4) pip install numpy
  • PF1
    PF1 over 3 years
    Same thing cropped up for me today. Looks like they removed the c compiler + associated make utilities in 3.9.0.
  • phi
    phi about 3 years
    Not sure, if subversion is necessary. The official Python docker base on buildpack-deps where subversion is not listed.
  • Admin
    Admin almost 3 years
    Thank you! This works for python3 + Alpine
  • Jack L.
    Jack L. over 2 years
    The same solution worked for a problem with MacOS on Big Sur