
We think SPSS with Python is great! However, you need to have the SPSS Python Essentials properly installed in order to use it. This tutorial gives a quick overview of installing and then testing them for different SPSS versions.
SPSS Python Essentials
The basic components you need for running Python in SPSS are
- SPSS;
- Python;
- the SPSS Python plugin.
Starting from SPSS version 18, Python, SPSS Python plugin and some extra modules are available as a single installer file known as the SPSS Python essentials. The table below gives a quick overview of how to get them and install them.
SPSS Version | Basic Installation | SPSS Python Essentials |
---|---|---|
21 or higher | Select SPSS Python Essentials during SPSS installation. | Only on SPSS installation medium |
18-20 | Install SPSS. Then install SPSS Python Essentials. | IBM SPSS website |
17 | Install SPSS, Python and then the SPSS Python plugin. | SPSS 17 Python Essentials |
16 | Install SPSS, Python and then the SPSS Python plugin. | Not available |
15 | Install SPSS, Python and then the SPSS Python plugin. | SPSS 15 Python Essentials |
14 | Install SPSS, Python and then the SPSS Python plugin. | Not available |
13 or lower | Not available | Not available |
SPSS Versions 21 and Higher
For SPSS versions 21 and higher, you need to select the SPSS Python Essentials during the installation process of SPSS. If you didn't do so, you'll have to reinstall SPSS with the Python Essentials from scratch. The SPSS Python Essentials for these SPSS versions are not available separately and can't be added to SPSS if it's already been installed.
SPSS Versions 18 Through 20
For these SPSS versions, you first just install SPSS. Tip: Google to see if there's any fixpacks for your version before proceeding: the precise version of the Python Essentials depends on which fixpack(s) you installed for SPSS.
Next, download the SPSS Python Essentials from the IBM SPSS website and install them.
SPSS Versions 14 Through 17
For SPSS 14 through 17, you first just install SPSS. Tip: Google to see if there's any fixpacks for your version before proceeding: the precise version of the Python Essentials depends on which fixpack(s) you installed for SPSS.
Second, install Python. It's important you install the exact right version (usually 2.5, 2.6 or 2.7). Third, install the SPSS Python plugin. Unfortunately, we couldn't find versions 14 and 16 anywhere online.
SPSS Versions 13 and below
Since Python for SPSS was introduced in version 14, you can't use Python with SPSS versions 13 and lower.
SPSS Python Essentials - Testing
A simple way to test if the Python Essentials have been succesfully installed is to run some syntax that uses Python. The syntax below provides for a quick test.
1 2 3 4 5 6 7 8 9 10 11 12 |
*1. Create mini test data. data list free/v1 to v5. begin data end data. *2. Try and retrieve variable names from test data. begin program. import spssaux print spssaux.GetVariableNamesList() end program. |
If the Python Essentials are running properly, you should see a Python list holding the variable names in your SPSS output window that looks like [u'v1', u'v2', u'v3', u'v4', u'v5'] (The ‘u’ here is for Unicode.) If the SPSS Python Essentials are not running properly, you'll get the error message in your output window shown below.
1 2 3 4 |
>Error # 6887. Command name: begin program >External program failed during initialization. >Execution of this command stops. Please make sure that Essentials for Python has been successfully installed. |
SPSS Python Essentials - File Locations
If something is not working, you may navigate to
for further inspection. If the Python Essentials have been installed, the File Locations tab should look like the screenshot below.

If you did not properly install the SPSS Python Essentials, the file locations for them will be greyed out as shown below.

For recent SPSS versions, you'll need to completely reinstall SPSS with the Python Essentials to fix the problem. That may take some effort but it'll be well worth it.
Thank you for reading!
THIS TUTORIAL HAS 46 COMMENTS:
By Ruben Geert van den Berg on October 22nd, 2020
Hi JungHee!
These commands are SPSS syntax and should be run in an SPSS syntax window rather than a Python shell.
Whatever lines (in SPSS syntax!) are between
BEGIN PROGRAM PYTHON3.
and
END PROGRAM.
are passed on to and processed by Python.
Read up on some of our other SPSS Python tutorials and you'll get the hang of it!
Hope that helps!
SPSS tutorials