V27 and Python

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

V27 and Python

Timothy Hennigar-2

SO – long time SPSS user with various computers running various versions. From SPSS 13 to 27.

 

(laff - still wanna see if I have my PC+ discs somewhere and can install on a XP virtual machine – for fun)

 

Know just enough about Python etc to be dangerous  -  have a few scripts I use routinely

 

V27 (an install not a subscription license) is informing me older Python scripts will be deprecated

shortly and I should update all my older scripts – Only not exactly sure where I call a SPECIFIC

version of python – would or what this exactly means -  will this be the only change needed –

will my scripts not run – they really are fairly simple things?

 

 

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: V27 and Python

Jon Peck
With V27, Python 2.7 is no longer provided by IBM, because it has reached the end of its support lifetime from the Python Software Foundation, and that means no more minor version updates if security issues are discovered.  (This is extremely unlike to be an issue with Python used with SPSS, but, whatever.)

You can still install Python 2.7 from the PSF site and then set Statistics to use that external Python distribution via Edit > Options >Files, but it would be better to switch to Python 3.  V27 supports Python 3.8.  V24 was the first version to support Python 3.

However, that requires converting Python 2 code to Python 3, since they are not entirely compatible, and changing the BEGIN PYTHON command within Statistics syntax files.  It is not possible to guarantee that mechanically converted code will be correct due to the dynamic type nature of Python and a few other issues, but I have created an extension command, STATS CONVERT PYTHON that will produce syntactically correct Python 3 code from .py or .sps files.  For BEGIN PROGRAM blocks, it extracts the Python 2 code, converts it, and puts it back with an updated BEGIN PROGRAM command.  It handles either single files or wildcard-specified batches of code.  It has a dialog box and syntax, and the syntax supports F1 help.  The actual changes to the Python code are done using a library that is part of the Python 3 distribution.

This extension is not yet posted to the Extension Hub, but you can get it from my OneDrive site here.
Download STATS_CONVERT_PYTHON.spe and install it using Extensions > Install Local Extension Bundle.  Of course, it does require Python 3.

As part of my testing of this extension, I took all of the example code from the Programming and Data Management book, which still is in Python 2, and converted it (can be done with just one use of the dialog box).  There are 121 code files in those examples, some of which don't actually include any Python code.  Only two failed conversion: one was actually syntactically invalid Python 2 code, and the other had a very weird XML xpath expression in a literal.  

Let me know of any issues encountered.  I hope to get this posted to the Extension Hub soon.



On Wed, Jan 20, 2021 at 11:17 AM Timothy Hennigar <[hidden email]> wrote:

SO – long time SPSS user with various computers running various versions. From SPSS 13 to 27.

 

(laff - still wanna see if I have my PC+ discs somewhere and can install on a XP virtual machine – for fun)

 

Know just enough about Python etc to be dangerous  -  have a few scripts I use routinely

 

V27 (an install not a subscription license) is informing me older Python scripts will be deprecated

shortly and I should update all my older scripts – Only not exactly sure where I call a SPECIFIC

version of python – would or what this exactly means -  will this be the only change needed –

will my scripts not run – they really are fairly simple things?

 

 

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD


--
Jon K Peck
[hidden email]

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD