Hacks and Tweaks


July 25, 2012

python mountain lion scipy error

More articles by »
Written by: arunenigma
Tags: , ,



Installing Octave under Mountain Lion. Solution to “illegal byte sequence” error.


Quick jot for memory on how to install octave + scientific python for Mountain Lion, since it’s pretty new for now .. These steps are kind of a mess since I’m not really documenting them in sequence.



1. Install Xcode 4.5 + command line tools

2. Install homebrew
$ /usr/bin/ruby -e “$(/usr/bin/curl -fsSL”

3. Test to make sure everything’s okay
$ brew doctor
$ brew update

4. Get Mountain Lion and Homebrew to Be Happy

Visit and download and install 2.7.2+.

$ sudo xcode-select -switch /Applications/

$ ln -s /opt/X11 /usr/X11

5. Install python using homebrew (will take a long time)
$ brew install python
(not necessary since OSX already has its own python)

6. Make sure python is at /usr/local/bin/python
$ which python

7. Install pip for python
$ easy_install pip

8. Install gfortran using homebrew
$ brew install gfortran

If this gives the error message:

Currently the gfortran compiler provided by this brew is only supports
the following versions of XCode
– XCode 3.1.4 on OS X 10.5.x
– XCode 3.2.2/3.2.3 — 4.0 on OS X 10.6.x
– XCode 4.1 or newer on OS X 10.7.x

$ brew edit gfortran

if MacOS.xcode_version >= ‘4.2’ and MACOS_VERSION > 10.7
ohai “Installing gfortran 4.2.4 for XCode 4.2 (build 5666)”
if MacOS.xcode_version >= ‘4.2’ and MACOS_VERSION >= 10.7
ohai “Installing gfortran 4.2.4 for XCode 4.2 (build 5666) or higher

(not necessary once the gfortran recipe is updated by homebrew)

9. Install scipy and numpy using pip
$ sudo pip install scipy
(scipy will fail with the following error)

/System/Library/Frameworks/vecLib.framework/Headers/vecLib.h:22:4: error: #error “<vecLib/vecLib.h> is deprecated. Please #include <Accelerate/Accelerate.h> and link to Accelerate.framework.”

see the ticket here:

get prebuilt binary from here instead:
the prebuilt binary cannot be installed either …

monitor the ticket to see if any solutions posted .. no scipy for now ..

$ sudo pip install numpy

10. Install pkg-config using homebrew
$ brew install pkg-config

11. Install gcc using homebrew (not necessary?)
$ brew install gcc –use-llvm

12. Install matplotlib

$ sudo mkdir -p /usr/local/include
$ sudo ln -s /usr/X11/include/freetype2/freetype /usr/local/include/freetype
$ sudo ln -s /usr/X11/include/ft2build.h /usr/local/include/ft2build.h
$ sudo ln -s /usr/X11/include/png.h /usr/local/include/png.h
$ sudo ln -s /usr/X11/include/pngconf.h /usr/local/include/pngconf.h
$ sudo ln -s /usr/X11/include/pnglibconf.h /usr/local/include/pnglibconf.h
$ sudo mkdir -p /usr/local/lib
$ sudo ln -s /usr/X11/lib/libfreetype.dylib /usr/local/lib/libfreetype.dylib
$ sudo ln -s /usr/X11/lib/libpng.dylib /usr/local/lib/libpng.dylib

If you get the error:
unable to execute clang++: No such file or directory
then do

$ sudo ln -s /usr/bin/clang /usr/bin/clang++

$ sudo pip install matplotlib-1.1.1.tar.gz

13. Install octave (will take a long time)
$ brew install fltk 

If fltk cannot be installed with the following error
Error: Failed executing: make install (fltk.rb:24)
Then just install octave without fltk first (it’s not crucial) .. until it’s fixed

$ brew install –with-magick-plus-plus GraphicsMagick

$ brew install octave –without-fltk
$ brew install gnuplot 

If you get this error while compiling Octave:

sed: RE error: illegal byte sequence

Error: Failed executing: make all (octave.rb:84)

Then unset the LANG environmental variable first

$ unset LANG

14. MacTeX, TeXShop and LyX
Finally, something that can be easily installed ..

Useful references:


About the Author

Computer Science Graduate Student @ Case Western Reserve University, Cleveland, USA



Python Factory Design Patterns using Switch Case

I googled for Factory Method Design Pattern in Python but couldn’t find a good resource. So, I  am sharing an example program to demonstrate this design pattern in Python which I frequently use. The factory method pattern is...
by arunenigma


Conway’s Game of Life Implemetation in Python with cool patterns

he Game of Life (or simply Life) is not a game in the conventional sense. There are no players, and no winning or losing. Once the “pieces” are placed in the starting position, the rules determine everything that ha...
by arunenigma


Python AVL Tree Implementation with ASCII visualization

n computer science, an AVL tree is a self-balancing binary search tree. It was the first such data structure to be invented. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any tim...
by arunenigma



Binary Search Tree in Python with ASCII art visualization

Binary search tree implementation in Python with: in, post and pre-order traversals. Also includes methods for insertion, deletion and search of nodes. Deletion is fairly complex and is made possible by keeping track of parents...
by arunenigma


Python, Memoization, Dynamic Programming, Fibonacci Series and some Fun!

ython can implement the recursive formulation directly, caching return values. Memoization is a method where if a call is made more than once with the same arguments, and the result is returned directly from the cache. For exam...
by arunenigma