Working with Multiple Versions of IBM SPSS Statistics (Python)

For versions 16.0 to 21.0, special considerations apply when multiple versions of the IBM® SPSS® Statistics - Integration Plug-in for Python (each associated with a major version of IBM SPSS Statistics, such as 20 or 21) are installed on your computer.

Running Python Programs from Within IBM SPSS Statistics

Important: This section only applies to versions 16.0 to 21.0.

By default, Python programs run from within the last installed version of IBM SPSS Statistics will automatically use the appropriate version of the plug-in. To run Python programs from within a different version of IBM SPSS Statistics, use the spss.SetDefaultPlugInVersion function to set the default to a different version (the setting persists across sessions). You can then run Python programs from within the other version. If you are attempting to change the default version from 16.0 to 17.0, additional configuration is required; please see the Notes below.

Running Python Programs from an External Python Process

Important: This section only applies to versions 16.0 to 21.0. For version 22 and higher, see Running IBM SPSS Statistics from an External Python Process.

When you are driving the IBM SPSS Statistics backend from a separate Python process, such as the Python interpreter or a Python IDE, the plug-in will drive the version of the IBM SPSS Statistics backend that matches the default plug-in version specified for that version of Python. Unless you change it, the default plug-in version for a given version of Python (such as Python 2.6) is the last one installed. You can view the default version using the spss.GetDefaultPlugInVersion function and you can change the default version using the spss.SetDefaultPlugInVersion function. The setting persists across sessions. If you are attempting to change the default version from 16.0 to 17.0 please see the Notes below.

Note:
  • If you are using the spss.SetDefaultPlugInVersion function to change the default from version 16.0 to version 17.0, you should also manually modify the file SpssClient.pth located in the Python 2.5 site-packages directory. Change the order of entries in the file so that the first line is SpssClient170.

    Windows. The site-packages directory is located in the Lib directory under the Python 2.5 installation directory—for example, C:\Python25\Lib\site-packages.

    Mac OS X 10.4 (Tiger). The site-packages directory is located at /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages.

    Mac OS X 10.5 (Leopard). The site-packages directory is typically located at /Library/Python/2.5/site-packages.

    Linux. The site-packages directory is located in the /lib/python2.5/ directory under the Python 2.5 installation directory—for example, /usr/local/python25/lib/python2.5/site-packages.

  • Beginning with version 15.0, a restructuring of the IBM SPSS Statistics - Integration Plug-in for Python installation directory and changes to some class structures may affect Python code written for an earlier version and used with a 15.0 or higher version. Specifically, the type of an object, as given by the Python type function, may return a different result. For example:

    cur=spss.Cursor()

    print type(cur)

    will return spss.cursors.Cursor when run with version 14.0, spss.spss150.cursors.ReadCursor when run with version 15.0, and spss.cursors.ReadCursor when run with a version higher than 15.0.