I've tried to find a solution for my problem in the Internet but none of them have worked.

So, the problem is that when I run this code in the SPSS syntax window:

begin program.

import spss

dataset = spss.ActiveDataset()

print(dataset)

spss.StartDataStep()

sav = spss.Dataset(dataset)

print(dataset.name)

print(len(sav.cases))

print(spss.GetVariableCount())

end program.

everything works fine. While I run the first and next the second line in the IDLE window I receive this message:

import spss

dataset = spss.ActiveDataset()

Traceback (most recent call last):

File "", line 1, in

zbior = spss.ActiveDataset()

File "D:\Programy\SPSS\Predictive Solutions\PS IMAGO >> PRO\5\IBM\SPSS\Statistics\25\Python3\lib\site-packages\spss\spss.py", line 1936, in ActiveDataset

raise SpssError(error)

spss.errMsg.SpssError: [errLevel 17] IBM SPSS Statistics backend is not ready.

Does anyone know what's going on?

Note: I'm a beginner both at Python and SPSS library for Python.