Sudo cd Python SPSS $*!@?? madness

Part 1

I recently had a trying experience trying to get the Python Integration plugin to play nice with my installation of PASW 18.0.3 (referred to as SPSS from here forward). Of course the first thing I did was fire up the Programmability External Python Process, which in turn launches the IDLE (in this case, my SPSS version called for 2.6 only). Next up was to import the module:

“>>> import spss”

Only there was apparently no SPSS module to import – or so the IDLE told me. So I got to work. I am not sure how or why I was able to figure this out – some credit, no doubt goes to the SPSS dev forum – but after about three hours, I finally got SPSS to work with the python integration plugin. The only reason I am writing this up is because I suspect that there may be other users out there with similar issues, especially if you, like me, have multiple versions of Python installed (which, by the by, also require different versions of Tcl/Tk).

So, the import spss syntax returned multiple errors, each following some tweak by me. One of the last had a line that read:

‘no support for 64 bit arch’

or something like that, indicating it needed to run in 32-bit mode (this is all on a late 2008 MacBook Pro running 10.6.8). To the Terminal! The (general) man page for python revealed a NEW, SUPER SECRET (to me) defaults write file for Python, allowing conversion back and forth between 32- and 64-bit versions using a simple, boolean operator. Also I discovered I could set my default version (for local or global installations) as well. See the general or version-specific python man page for instructions.

Unfortunately, I was not finished, as there was still no spss module to import. After lots of digging, I found the answer: they were installed, but not where they were supposed to be. I verified this by checking my $PATH. At that point, I moved the files from:

/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages

to:

/Library/Python/2.6/site-packages

and then switched to 32 bit mode in the terminal. Success!

I got it to work, and everything was kicking along beautifully (for a bit). This whole thing was probably more brute-force than it should have been or needed to be. For example, I should have just added the first path to sys.path, instead of moving directories, but I was really, really, really tired at that point and could not think. I thought things were all square, until…


Part 2

…about a month later, when I had another odd, frustrating and harrowing Python Integration experience. The whole process quit working again. After hair pulling, checking and resetting my preferences via BASH, I was about at my wit’s end. Then, almost completely by accident, I noticed that my SPSS version was listed as 18.0.0. There was no way this could’ve been the case: I had applied the (joke of a) hotfix from IBM to 18.0.3. Somehow, somewhere, my installation of PASW was effectively downgraded from 18.0.3. to 18.0.0. It sounds impossible, and it is an absolute mystery to me. Oh, and then there was the IDLE: it went from 2.6.2. to 2.6.1. This is also bizarre. It’s more than bizarre. Rather than sit there with a stupid look and try to doubt the facts, I spent another three hours downloading the SPSS upgrade, checking files, unsuccessfully uninstalling and reinstalling the external Python plugins, etc. (note: I did have a clone backup, but to get things just right on a restore would have been even more of a pain in the ass, at least for me).

Here’s what I found/learned along the way:

  • Plugin 18.0 identified Python’s location as ‘usr/bin/’, which I initially thought was okay because there was a symlink to the actual location. This configuration did not work as symlinks are apparently not followed like they should be.
  • Plugin 18.0.2 identified Python’s location as ‘Library/Frameworks/Python.framework/Versions/2.6/bin/’, which was where the install actually was. This was helpful.

Everything was up and running again. I hope I don’t have to deal with whatever this was again. If you’re having similar issues with SPSS and Python playing nicely, reinstall the external launcher from the SPSS install disc and then (re)upgrade the plugin after upgrading the SPSS software. In list form (to solve part 2):

  1. Install core SPSS (if starting from scratch install, otherwise skip this)
  2. Install packages of your choice, including Python External Programmability Process, from your install DVD
  3. Download and install SPSS upgrade(s) if necessary
  4. Download and install Python plugin upgrade

This might just be specific to my version (version 18.x.x), but the factory supplied plugin installed itself (by default) in a non-path directory. Symbolic links won’t cut it, so don’t rely on them to point to a non-$PATH directory. The upgraded plugin puts itself in your $PATH. If you’re like me and are too lazy or tired to add the non-standard directory to your $PATH, then this is how to fix your busted install.

Advertisements

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