Quick fix to pip install error

I recently created some python scripts that I wanted to run periodically to update some information for me. I got the scripts running the way I wanted and decided to move them over to my Mac Mini where I knew they could run uninterrupted throughout the day. One of the steps I had to take was update my Python environment on my Mac Mini to match my MBP. After installing a few modules I ran into a problem with the PIL/Pillow module. After several attempts at running pip install Pillow, I would end up the with following error:

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 'cc' failed with exit status 1

Hmm…. I’m the first to admit I’m a total newbie when it comes to deciphering install errors like this, so I poked around stackexchange for an answer. Sure enough, someone had already posted something similiar: 1

The Apple LLVM compiler in Xcode 5.1 treats unrecognized command-line options as errors. This issue has been seen when building both Python native extensions and Ruby Gems, where some invalid compiler options are currently specified. Projects using invalid compiler options will need to be changed to remove those options. To help ?ease that transition, the compiler will temporarily accept an option to downgrade the error to a warning:

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

Further reading from the Xcode release notes shows:

As of Apple LLVM compiler version 5.1 (clang-502) and later, the optimization level -O4 no longer implies link time optimization (LTO). In order to build with LTO explicitly use the -flto option in addition to the optimization level flag. (15633276)

  • The Apple LLVM compiler in Xcode 5.1 treats unrecognized command-line options as errors. This issue has been seen when building both Python native extensions and Ruby Gems, where some invalid compiler options are currently specified.

Projects using invalid compiler options will need to be changed to remove those options. To help ease that transition, the compiler will temporarily accept an option to downgrade the error to a warning:

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

Note: This option will not be supported in the future.

To workaround this issue, set the ARCHFLAGS environment variable to downgrade the error to a warning. For example, you can install a Python native extension with:

$ ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future easy_install ExtensionName

Similarly, you can install a Ruby Gem with:

$ ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install GemName

So now the proper method to do a ‘pip install’ is:

ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install pillow

Boom! Pillow installed with no problems and my python script loaded with no issues.


  1. Answer from StackExchange - Can’t install mysql gem on OS X 

Python PIP

Comments

Top