This was stolen from my teachers website, this could be a helpful guide to setting of Python and numpy correctly on a Mac
The combination of Python, NumPy (Numerical Python), SciPy (Scientific Python), and OpenCV provides you with a free, open source programming environment that is ideal for imaging-related applications. You will have access to a huge collection of community-developed codes for linear algebra, matrix algebra, linear mathematics, computer vision, and image processing. You will also have access to an up-to-date collection of image acquisition routines for both still and video digital cameras. Rounded out by a full suite of input/output routines for a myriad of image and video file formats, this environment will provide you with a rich development and research capability.
You will need to have Apple's XCode installed on your computer.
If you are running Mac OS X 10.7 (Lion) or later (Mountain Lion), the latest version of XCode can be downloaded from the App Store. This is a large download (approximately 4GB) so you may want to connect your machine to the wired network during installation.
If you are running Mac OS X 10.6.8 (Snow Leopard), you will need to download XCode 3.2.6 from the Apple Developer site. You need to be signed up to the free Apple Developer program in order for this to work, and note, that this is an end-of-life product that will no longer receive updates. If possible, you should consider upgrading to the most recent version of Mac OS X.
Once XCode is installed, you will want to download and install the command line tools. Start XCode and go to
XCode > Preferences... > Downloads
and install the "Command Line Tools".
You will now need to install MacPorts on your system. The MacPorts Project is an open-source community initiative to design an easy-to-use system for compiling, installing, and upgrading either command-line, X11, or Aqua-based open-source software on the Mac OS X operating system.
Now you are ready to install Python and the various modules mentioned above. Open up a terminal window
Applications > Utilities > Terminal
and issue the following commands (be very careful what you type, executing these commands with sudo means you are operating as the root user on your machine, and as such, you could do some real damage if you issue an incorrect command):
$ sudo port selfupdate
$ sudo port install python27
$ sudo port install py27-tkinter
$ sudo port install py27-numpy
$ sudo port install py27-scipy
$ sudo port install qt4-mac
$ sudo port install opencv +python27+eigen+qt4+tbb+dc1394
$ sudo port install py27-matplotlib
$ sudo port select --set python python27
expected. The default shell on your Mac "out of the box", as in most modern Unix operating systems, is bash. Your default environment is controlled by a couple of resource files, located in your home directory, that get executed upon startup of the shell; these are .bash_profile and .bashrc. Using your favorite text editor, create or modify these files making sure that they minimally contain the following (note that these are "hidden" files and are most easily accessed from the command line):
.bash_profile
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
.bashrc
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
if [ -x /usr/libexec/path_helper ]; then
export PATH=""
export MANPATH=""
eval `/usr/libexec/path_helper -s`
fi
export PATH=/opt/local/bin:$PATH
export MANPATH=$MANPATH:/opt/local/man
export PYTHONPATH=<path-to-your-python-modules>
The indicated on the last line should indicate the location of any personally developed Python modules that you have written or will write that you would like to be available to all the codes you write on your machine, regardless of the location that you develop them in. For example, you might create a directory in your home directory by typing
cd
mkdir src/python/modules
where you intend to store all of your personal Python modules. Your PYTHONPATH envrionment variable in the .bashrc file should then be
export PYTHONPATH=$HOME/src/python/modules
Now to see if it works
$ python
>>> import numpy
>>> import scipy
>>> import cv2
>>> numpy.__version__
>>> scipy.__version__
>>> cv2.__version__