While setting up a Python data-science stack within a fresh virtual environment on my Mac running OS X 10.10.1 (Yosemite), I encountered several frustrating errors. Below, I outline the steps I took that eventually led to a successful installation.

Initially, my main objective was to install version 0.15.2 of scikit-learn using pip install -U scikit-learn. However, I encountered errors during the scipy installation process. While numpy 1.9.1 was successfully added, scipy 0.15.1 installation failed. I attempted to install scipy 0.15.1 individually but encountered the following error:

[Error message]

After conducting a few Google searches and some trial and error, I attempted a fix based on instructions found in a StackOverflow post. Despite following these instructions, I still encountered errors. Here are the initial steps I took:

  1. Download and install XCode Command Line Tools from Apple.
  2. Installing scipy continued to fail at this point.
  3. Executed sudo xcode-select –switch /Applications/Xcode.app/Contents/Developer/.
  4. Ran brew update followed by brew doctor.
  5. Attempted pip install -U scipy, which failed with the same error message.
  6. Found suggestions in a random README file and executed the following:
bash
export CC=clang
export CXX=clang++
export LDFLAGS='-L/opt/X11/lib'
export CFLAGS='-I/opt/X11/include -I/opt/X11/include/freetype2'

However, this resulted in a new error message:

[New error message]

Based on a couple more posts, I decided to unset LDFLAGS and CFLAGS. After doing so, I attempted to install again but encountered the same error message as before.

At this juncture, feeling quite frustrated, I closed my terminal iTerm2 and reopened it. Omitting the LDFLAGS and CFLAGS options, I set:

bash
export CC=clang
export CXX=clang++

This time, I successfully installed both scipy and scikit-learn without encountering any errors.