Getting a sensible Python install on my Mac

Author

Michael G. Lerner

Published

December 18, 2011

I recently had to get Python + things I like up and running on my Mac from scratch. That’s a significantly harder task than you might guess, so one of the main reasons I’m posting this is for my own benefit (I’ll have to do this all again in February when I give my current laptop back to NIH and buy one of my own). There’s a decent chance this will be useful for others, though. A significant amount of experience and gnashing of teeth has told me

  1. ActiveState is awesome, but not everything works perfectly with it.
  2. Ditto for Python 2.7.
  3. Never mix macports and fink.

    So, here’s my setup for a working python2.6 system that happens to meet my current needs:

    1. Fully uninstall macports (http://guide.macports.org/#installing.macports.uninstalling). Follow the full set of directions.

      1. Install the latest and greatest macports, using the package install and the easy options (http://guide.macports.org/#installing.macports).

        1. Make variants.conf reject all python2.7-related things
          [lernerm@LCBB-ML01777274 ~]$ cat /opt/local/etc/macports/variants.conf
          # To specify global variants to use for all port builds,
          # customize this file to list variant settings you want.
          #
          # Any variants specified here that are not supported by
          # a port will just be ignored. Multiple variants can be
          # specified per line, or one per line is also allowed.
          #
          # Example:
          # +ipv6 +no_x11
          +py26 +python26 -py27 -python27 +bash_completion

          1. Make sure you can install some basic things. I start with bash completion (https://trac.macports.org/wiki/howto/bash-completion) and coreutils.


            sudo port install bash-completion
            sudo port install coreutils +with_default_names

            Note that you’ll have to edit your .bash_profile to make bash-completion work. It’s documented in the link above. You may also have to add /opt/local/libexec/gnubin to your path to get coreutils to work.

            1. Install the Python environment I want, including

add the following to CMakeLists.txt:


set(CMAKE_LIBRARY_PATH /opt/local/lib ${CMAKE_LIBRARY_PATH} )
set(CGAL_DIR /opt/local/lib/cmake)

That’s not enough. Edit CMakeCache.txt by hand to point at the right Python by searching for /System/Library/Frameworks/Python.framework and replacing it with /opt/local/Library/Frameworks/Python.framework and then, finally,


make

And then make sure that \(HOME/src/Dionysus/build/bindings/python is in your PYTHONPATH.</p> <p>6c) orange (from source http://orange.biolab.si/nightly_builds.html)</p> <p><code><br> python setup.py build<br> python setup.py install -user<br> </code></p> <p>Note that the last bit requires you to have this in your .bashrc or .bash_profile (or both, or maybe they’re the same file because you’ve symlinked them!):</p> <p><code><br> export PYTHONPATH=\)HOME/.local/lib/python2.6/site-packages:$PYTHONPATH

Whew!

Comments from previous blog