Installing Python (Mac OS)

Instructions below were contributed by Robert Branton.


Here is final synopsis of what I did to install and run spyder on Mountain Lion.

  1. install XQuartz – http://xquartz.macosforge.org/landing/
  2. update to latest python – http://www.python.org/download/releases/3.3.0/
  3. install Tcl/Tk – http://www.python.org/download/mac/tcltk/
  4. install XCODE from App Store
    • build Command Line Tools
  5. install MacPorts – http://guide.macports.org/
  6. activate Mac OS Terminal window to get $ prompt and so run MacPorts
    • $ sudo port install py-spyder
    • $ sudo port -f activate python27
    • $ sudo port install py-spyder
    • $ sudo port uninstall py27-matplotlib-basemap
    • $ sudo port install py27-matplotlib-basemap
    • $ sudo port install py27-netcdf4
  7. to run spyder form Mac OS Terminal
    • $ spyder-2.7 &
  8. to cleanup spyder workspace
    • $ rm -R .spyder2-27/
Advertisements

7 thoughts on “Installing Python (Mac OS)

  1. Things I did to install and run spyder on Mountain Lion

    1) install XQuartz – http://xquartz.macosforge.org/landing/

    2) update to latest python – http://www.python.org/download/releases/3.3.0/

    3) install Tcl/Tk – http://www.python.org/download/mac/tcltk/

    4) install XCODE from App Store
    — build Command Line Tools

    5) install MacPorts – http://guide.macports.org/

    6) active the Terminal window
    $ sudo port install py-spyder
    $ sudo port -f activate python27
    $ sudo port install py-spyder
    $ spyder-2.7 &

    Given this was my first attempt at Macports, it required lots of trial and error.

    • I successfully replicated all the first OceanPython.org tutorial.

      I could not however get past line 1 of the Global RTOFS … example

      >>> from mpl_toolkits.basemap import Basemap
      Traceback (most recent call last):
      File “”, line 1, in
      ImportError: No module named basemap
      >>>

      Using Google I found …

      http://comments.gmane.org/gmane.comp.python.matplotlib.general/31359

      With the following hint …

      ‘You are not running macports python (you’re running Apple python). Try running /opt/local/bin/python27, and then import basemap.’

      Looking at my console on startup I see ….

      Python 2.7.3 (default, Nov 17 2012, 19:54:34)
      [GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin
      Type “help”, “copyright”, “credits” or “license” for more information.

      Imported NumPy 1.6.2, SciPy 0.11.0, Matplotlib 1.2.0
      Type “scientific” for more details.
      >>>

      Where to go from here???

  2. solution is exit spyder and then activate the terminal window …

    $ sudo port uninstall py27-matplotlib-basemap

    $ sudo port install py27-matplotlib-basemap

    $ spyder-2.7&

    and then had to change script line 7 from

    import netCDF4

    to

    import Scientific.IO.NetCDF as netCDF4

    as it turns out, the rtofs_glo_3dz_f120_daily_3ztio.nc file is 1.9 GB and is difficult to download via wirelss, perhaps I can get it on a thumbdrive

  3. This is a fantastic tutorial, many thanks!
    I have tried to follow the instructions step by step, and I do manage to open Spyder from the terminal. However, when I try and run any program, it quits with the error message “Python quite unexpectedly”. Having googled around, and also given the fact that in my terminal I get such warnings:
    “libpng warning: iCCP: cHRM chunk does not match sRGB”
    I am starting to think that I have a problem with the graphics. I did install Tcl/Tk as per step 3. I have also installed py27-pyqt4 (via macports) but still have the same problem with Python quitting.
    In /usr/bin/ I have
    tclsh -> tclsh8.5
    tclsh8.4 -> ../../System/Library/Frameworks/Tcl.framework/Versions/8.4/tclsh8.4
    tclsh8.5 -> ../../System/Library/Frameworks/Tcl.framework/Versions/8.5/tclsh8.5
    Could it be that I am linking to the wrong tcl/tk, or that it is in the wrong location?
    Grateful for any advice,
    Rakia

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s