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
To use the Python 3 processor for Python code within a program block, use BEGIN PROGRAM PYTHON3-END PROGRAM.
To run a script that uses the Python 3 processor, use PYTHONVERSION=3 on the SCRIPT command.
To use the Python 3 processor for an extension command, specify LanguageVersion="3" along with Language="Python" in the Command element of the XML specification for the extension command.
Python 3 in the user interface
Scripts that are run from the Python script editor, opened from File > New > Script or File > Open > Script.
Scripts that are run from Utilities > Run Script run in the Python 3 version that was selected on the Run Script dialog.
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:
Open a command line instance and go to the SPSS Statistics installation path (bin folder on UNIX).
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
Python scripting and com scripting does not work when the application is in Workbook mode (Edit > Options... > General > Application Mode).
The Python runtime environment does not work after you uninstall IBM SPSS Statistics and reinstall to a different path. To resolve the issue you must remove the virtual Python environment (Python39 directory).Windows: %APPDATA%\IBM\SPSS Statistics\28\Python39
macOS: ~/Library/Application Support/IBM/SPSS Statistics/28/Python39