Running Python code with Python

Python 2 is no longer installed with IBM SPSS Statistics.

Install Python 3.9.1 with version 28 and Python 3.10.4 with version 29


For release 28 and higher, the IBM® SPSS® Statistics - Integration Plug-in for Python supports code that is written in Python 3.9.1. All functions and classes that are available with the Integration Plug-in for Python are supported in Python 3.9.1. In addition, a Python 3.9.1 distribution is installed with the IBM SPSS Statistics. 

Important: Use of the Python 3 processor requires that IBM SPSS Statistics is in Unicode mode. For more information, see SET command, UNICODE subcommand.

Python 3 runtime environment

The Python 3 runtime environment is accessed by clicking the Python 3 IDLE (PythonGUI) (Windows) or Python 3 for SPSS Statistics (macOS) option in the product folder. The runtime environment can also be activated via command line by running the statisticspython3.bat (Windows) or statisticspython3 (UNIX) script. The script is located in the IBM SPSS Statistics installation path (bin folder in UNIX).

Python 3 in command syntax

Python 3 in the user interface

External Python 3 distribution

To use an external Python 3 distribution, set the home path of the external distribution in the Python 3 home directory field (Edit > Options > File Locations > Python 3 Location > Other installation of Python 3). For IBM SPSS Statistics Server, update the Python 3.9 home path in the spssdxcfg.ini file's [Python3] section. The file is located in the SPSS Statistics installation path (bin folder on UNIX). For example:

[Python3]

HOME=

LIB_NAME=InvokePython39

Python 3 3rd party packages

The following steps explain the process of manually installing 3rd party Python 3 packages:

  1. Open a command line instance and go to the SPSS Statistics installation path (bin folder on UNIX).
  2. Run the statisticspython3 script with -m pip install <package_name1> <package_name2> to install packages. For example, enter the following command to install the numpy and scipy packages.Windows:
    statisticspython3.bat -m pip install numpy scipy
    UNIX:
    statisticspython3 -m pip install numpy scipy

Known issues