Tuesday, January 1, 2013

Installing Python and its friends on Mac

1 Installing Homebrew, Python, and PIP

1 Installing Homebrew, Python, and PIP

Both Homebrew and PIP are package managers available on Mac.

  • Homebrew makes plenty of softwares and packages more accessible.
  • PIP makes packages/modules for Python easier to manage.

1 Homebrew

Paste this into the terminal:

sudo ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"

And set the path so the Homebrew knows where to put your stuff:

export PATH=/usr/local/bin:/usr/local/share/python:$PATH

Normally you will find your scripts and packages installed under:

/usr/local/share/python/

2 Python

This is a one liner:

brew install python

3 PIP

We will install PIP using Homebrew:

easy_install pip

2 Installing NumPY, SciPY

1 NumPY

sudo pip install numpy

2 SciPY

brew install gfortran
sudo pip install scipy

3 Running Python

Start the IDLE that came with the installation of Python, and try these following lines:

import numpy
import scipy

Try to build it. It should work.

The references to these two very useful modules are easily accessible by one or two google search. I don't want to bother you guys with functions detail. Try this:

help(numpy)

3 Make a cosy room for Py

The original IDLE isn't great enough for running Python, I personally recommend you to use Sublime Text. It's just simply awesome.

Remember to select the build system to be Python or Automatic (which selects the correct one based on the extension of the filename).

Happy coding with Python!

BTW, happy new year!

No comments:

Post a Comment