Monday, November 7, 2011

Installing Pythonika

Pythonika enables Mathematica to run python.  I ran into some problems installing it with Mathematica 8 and Lion 10.7.2 OS X from the official pythonika webpage.  Here are some quick tips for those performing a similar install.

  • download my appended version, here
  • install 64-bit Python 2.7.1, here 
  • soft link mathlink.framework inside the Mathematica application into the /Library/Frameworks directory using this command in the terminal
    • ln -s /Applications/Mathematica.app/SystemFiles/Links/MathLink/DeveloperKit//CompilerAdditions/mathlink.framework ~/Library/Frameworks/


In my appended version, the main modifications were to the file Makefile.osx.  For everything to compile properly the new makefile changes the CADDSDIR to point to ${MLINKDIR}/CompilerAdditions, deletes the SYS path, specifies CC=g++, and adds -lstdc++ before -framework CoreFoundation.  Simple examples on how to use pythonkia can be found in the Pythonika.nb file on the google codes site.

2 comments:

  1. I would love to use Pythonika for Mathematica 8 on my Mac but I have very little experience compiling things The various threads on this subject are rather intimidating. When I attempt to install "Pythonika-Mathematica8-Python2.6" on my Mac I get the following error message: LinkOpen::linke: Specified file is not a MathLink executable. As I understand it, the problem can be cured by recompiling Pythonika with certain flags. That's great, but might it be possible for someone to post a pre-compiled version that will actually run on Mathematica 8. I loved Pythonika on earlier versions of Mathematica and would like to use Natural Language Toolkit again from within Mathematica, but unless I summon up the courage to do some compilation, I will be blocked. Is there any way you could post a working executable for OSX 10.7 and Mathematica 8 Version 8.0.1 or above. Thanks so much. SJC

    ReplyDelete
  2. mathlawguy,

    Sorry for taking so long to get back to you. There are a great variety of problems that can pop up when trying to install Pythonika. So I have a few questions.

    Did you install 64-bit Python 2.6 for OS X 10.7?

    If you used my appended Pythonika installation (from the first bullet point) did you change "PYTHON_VERSION_MINOR = 7" to "PYTHON_VERSION_MINOR = 6"?

    ReplyDelete