A Lifesaver called MacPorts

In this article, I shall outline the convenience of installing MacPorts. If you haven't already, install it immediately.

You are welcome!

Now, lets see how we can use it. For installing a particular package, say the latest version of python, you need to do the following steps.

  1. Go to the MacPorts site, and go to the 'available ports' page.
  2. Type python into the search box. You will get everything that is remotely associated with python. The latest stable version (3/17/2010) is Python 2.6.4. Look for that package. It will be listed as python26, along with all its dependencies. 
  3. To install it, open the Terminal, and  type in the words,
    sudo install python26
  4. Type in your password (not the root password, your password).
  5. Sit back, and enjoy as ports checks dependencies, and installs everything that is required for the installation of python 2.6.4.
Now, however, you are stuck with two installations of python. The older version that came with the Mac, located at /usr/bin/python2.6, and the newer one found at /opt/local/bin/python2.6. However, note that if you directly type python at the terminal, you will still end up running the older version of python. Thats because, if you try to find the location of python (type which python in the Terminal), which happens to be a link to /usr/bin/python2.6. Thus, to use the MacPorts version, there are two options. 

  1. Execute it directly - type the whole path /opt/local/bin/python2.6.
  2. Update .bash_profile to modify your path to
    PATH=/opt/local/bin:/opt/local/sbin:$PATH.
Now, if we already have one version of python, why do we need another version? Because, if you are a scientist or an engineer, and want to install scipy, the conventional method just wont work. So, what do you do? Install scipy via MacPorts. and do your simulations using the new version. 

Finally, install mayavi. Which I am doing right now, while writing this article. 

1 comments:

Sankha Mukherjee said...

Mayavi cant install - apparently wxwidgets through macports is a problem. Not sure how to manually install it. :)

Post a Comment