Having recently acquired the use of a Macbook Pro, I have spent the better part of a week setting it up to enable me to use it to get things done. This is my first mac for nearly a decade, and while it certainly has many of the capabilities of Linux, it’s BSD and Mac heritage mean that many things are very different. There are a few guides available for setting osx up as a scientific computing environment, and i’ve included some of these as links. So here it is – my first scientific mac programming environment.
Install Fink and/or Macports
Fink is a package manager that provides you with the same convenience of package installation as Linux package managers. I prefer Macports to fink – the documentation is superior for one, and as a BSD heritage project it’s more in line with osx, which is BSD, not Linux. Still, I’ve kept fink. Installation of both should be painless, and as they put their bits in different directories, they should not conflict with one another.
However, fink and macports both can install libraries that conflict with default system libraries during the build processes of some packages (I found this with older versions of Matplotlib, and CDAT in particular). It can be hard to track these issues down.
If you’re into vim, you’ll want MacVim
MacVim is really quite nice, not as unstable now as earlier releases were. It will start faster than the gvim you get from macports.
An earlier attempt to
fink install vim
caused fink to install a crapload of dependencies, and it then turned out that some of the libraries conflicted with system libraries down the track when i was trying to get matplotlib working. The vim install failed the first time while compiling gtk stuff something to do with libXrandr, which should be in X11. Discussion of the vim install issue Apparently this bug has been fixed in version 2.2 I forget how to configure vim to not lock up the shell window, but mvim does this automatically.
svn is installed by default.
I installed the latest macpython binary (python-2.5.2-macosx.dmg) before building scipy. After install, I needed to add the System python path back to PYTHONPATH, so that system installed packages can be loaded when running the macpython python.
\Library\Python is for user modules for the system python
\Library\Frameworks is for macpython
PYTHONPATH = PYTHONPATH + /System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/pythonpath
Update: Python 2.6has been out for a little while, but a bit of googling suggests that support for the big three scientific packages is not total yet. I’ve held off upgrading – your mileage may vary.
There are many detailed guides for installing Scipy on various platforms: I followed the instructions at www.scipy.org/Installing/SciPy/Mac_OS_X. I strongly suggest reading and following these instructions, and others like it that are more likely to be up to date than this post, for example Py4Science, and this mtheory guide. For what it’s worth the rest of the steps I took to get scipy up and running follow.
Download binary (71MB!!) from http://r.research.att.com/tools. Installed in /usr/local. Added /usr/local/bin to path.
sudo gfortran uninstall to remove. Note: programs are dynamically linked with libs in /usr/local/lib. For portable binary link statically.
instructions on scipy page – configure, make and install.
I compiled the SVN version – no problems with the instruction. – scipy failed one test – not too bad :-) You will need to install Nose for scipy.test() to work.
IPython is really great and I thoroughly recommend it.
Need to install an egg that links scipy statically against the gnu readline library (and not the bsd one) After doing this ipython installed and works with no dramas.
Turns out you need to be aware at install time if you are running two python distributions. There is a script to put in your bin directory and an app for the applications folder.
Installing tex took a while… 1.6 GB required.. I now find that texmaker is my favourite tex editor. It has better support for multiple files with includes than Texshop.
Installed, but doesn’t seem to want to talk to X. Trying macports again. Not sure how I got this to work exactly. I find that sometimes if I’m using X with a session on another machine Imagemagick display won’t work.
This was a bit of a saga, and the subject of a thread on the matplotlib discussion list. Had some hiccups installing matplotlib, but it now seems to be working. Recently I have had no trouble installing the recent eggs. Not sure if I’ve done a build from scratch – numpy and scipy I build regularly, but I tend to just grab the eggs for plotting.
1. Install setuptools for macpython
2. Downloaded the egg and run
sudo easy_install matplotlib-0.91.2-py2.5-macosx-10.3-fat.egg
You may need to fix the name of the egg, otherwise it tries to download and build the package (this issue should now have been resolved). Some notes on my building problems follow.
I thought the problem is the same as for ipython – need to specify the install directory, but this is not the case – as long as the macpython is earlier in your path than the system python it seems to pick up the right one. It was picking up the correct directories, but failing when linking to libjpeg. Looked like it was trying to build for ppc.
Thought it may have been that I needed freetype – installed freetype2 with fink. Turns out the default freetype libraries under x11are sufficient, though. libpng and zlib seem to be included in the default install too.
Downloaded wxpython dmg to install just ran the pkg file. installed wx python – didn’t fix the matplotlib issue.
Library\Frameworks\Python\Versions\2.5\lib\python2.5\site-packages contains numpy, scipy and IPython directories
\Library\Python\2.5\site-packages has a numpy and nose directories, and a readline egg. Confusion
The \System python site packages directory doesn’t appear to have any packages i’ve installed
Now I have removed /sw libjepg. I removed the fink libjpeg, and now it failed on libtiff. Charles Barker on the list said this is because easy_install is trying to build a universal binary, but the fink libraries are not universal. So can’t I build a non-universal matplotlib?
Did fink remove libtiff: this time the matplotlib egg install seemed to work, but it wouldn’t import. I think the import error was because I was running python in the directory with the egg in it.
General instructions for using easy_install at (It’s from this resource that I got the advice from pkg_resources import require require(“SomePackage”, “OtherPackage”, “MyPackage”)
Followed the pkg-config instructions at http://ipython.scipy.org/moin/Py4Science/InstallationOSX Advice for compiling matplotlib from source (which I didn’t end up doing): Edit “setupext.py” near line 50, the “basedir” variable. We want to avoid linking in third party libraries. Change: ‘darwin’ : [‘/sw/lib/freetype2’, ‘/sw/lib/freetype219’, ‘/usr/local’, ‘/usr’, ‘/sw’, ‘/usr/X11R6’], To: ‘darwin’ : ,
Notes: need to use pythonw not just python to launch programs that need guis.
Mount ext3 file system
http://ubuntuforums.org/showthread.php?t=614948 http://sourceforge.net/project/showfiles.php?group_id=64713&package_id=101149 Installed the developer version of this package
os x needs my avi’s to be called avi. ok. i also need to download the windows codec install divx? I don’t want the player, just the codec. I didn’t need divx, just the windows media for mac pack, available from the microsoft website.
First step was to get python working with netcdf file. Jeff Whitaker’s python netCDF interface is similar to the Scientific.IO one but better (better maintained, better functionality, better everything). It requires HDF and netcdf 4. I had little joy installing either via fink, macports, or straight binaries, and much more luck building both HDF and netCDF from source. Unidata recommend building the daily snapshot (probably old advice now). Followed the instructions at: http://www.unidata.ucar.edu/software/netcdf/netcdf-4/newdocs/netcdf-install/Quick-Instructions.html Doesn’t appear to have fortran support for HDF – probably don’t need it?? Didn’t do a shared build. Changed my mind about netcdf4 I don’t want compatibility issues! Used sudo port install netcdf. Since have built the released verson of netcdf4, with no issues.
Then followed the instructions for installing for netcdf 3 at http://netcdf4-python.googlecode.com/svn/trunk/docs/netCDF3-module.html
I think I just did sudo port install mplayer
Still to do:
install gnome terminal? or konsole? link gvim to mvim copy .vimrc (where does mvim look for settings?):w install gimp install octave install tex-live (use mactex distro) DONE install inkscape install pyglet (DONE)5: install netcdf4 for python install gtk and other potential backends for matplotlib
I have never been able to successfully build and run CDAT on my Mac. Others swear that they have. It’s a nice package, but in the end I’ve found it not really suitable for my needs. The community around it doesn’t seem sufficiently large that bugs are fixed in a timely fashion, and the documentation is a hard to navigate. I think the guys who maintain and develop it do a great job but it seems they are under-resourced and/or over-ambitious.
To show all files defaults write com.apple.Finder AppleShowAllFiles YES
Figure out how to use the one program for local terminals and gale sessions that will open X11 windows. (Terminal seems to work fine now that I’ve reverted a few .cshrc changes).
Read the screen tutorial
Find a terminal replacement (gnome? iterm is not open source)
Sphinx and Docutils
I love sphinx. It’s great for making linkable docs for various projects, for PDF-ifying a readme file, and even for making drafts of scientific papers. And now it’s just easy_install -U sphinx.
General Mac science guidelines