Original Message:
Sent: 4/2/2025 11:01:00 AM
From: Art Jack
Subject: RE: running a python script within spss
I'm a little hesitant to change any python configuration because i'm also using the spss installed python for lots of other things. I'll probably just set up another process outside through subprocess.
Is there a way to link batch jobs with dependencies? I've asked a similar question before when i came across the luigi python module. I haven't been able to implement it though. I have many dependent SPSS & Python scripts running but if one fails (or runs out of turn) it can get complicated.
------------------------------
Art Jack
------------------------------
Original Message:
Sent: Tue April 01, 2025 06:37 PM
From: Jon Peck
Subject: running a python script within spss
That does look like a Python version mismatch. What do you see if you run
import sys
print(sys.__version__)
from within SPSS and via standalone?
You would need to modify the PYTHONPATH setting to get the right Python version or maybe do a SET command to point to the SPSS version in the bat file before invoking Python.
--
Original Message:
Sent: 4/1/2025 3:26:00 PM
From: Art Jack
Subject: RE: running a python script within spss
when trying to run a subprocess block i'm getting this, i'm reading this as i have conflicting libraries which makes sense:
Error: Traceback (most recent call last):
File "C:\General Syntax 24-25\alc.py", line 9, in <module>
import glob
File "C:\PROGRA~1\IBM\SPSSST~1\Python3\Lib\glob.py", line 5, in <module>
import re
File "C:\PROGRA~1\IBM\SPSSST~1\Python3\Lib\re.py", line 125, in <module>
import sre_compile
File "C:\PROGRA~1\IBM\SPSSST~1\Python3\Lib\sre_compile.py", line 17, in <module>
assert _sre.MAGIC == MAGIC, "SRE module mismatch"
^^^^^^^^^^^^^^^^^^^
AssertionError: SRE module mismatch
ERROR : (1) No error.
Traceback (most recent call last):
File "C:\General Syntax 24-25\alc.py", line 12, in <module>
import pandas as pd
ModuleNotFoundError: No module named 'pandas'
I've tried a few different host command ways. One calling the .PY file directly & another try to run a .bat file. I haven't found much documentation on how to use it, & am probably missing a step. I'm getting exit status 001, and a unicode error other times.
------------------------------
Art Jack
Original Message:
Sent: Tue April 01, 2025 09:28 AM
From: Jon Peck
Subject: running a python script within spss
Within SPSS, the Python invoked would be the one set up by the virtual environment, but it still ought to run unless it uses something incompatible with Python 3.10. If it depends on some module not on the Python path, you would need to augment PYTHONPATH before invoking HOST.
What is the error you are getting?
--
Original Message:
Sent: 4/1/2025 9:08:00 AM
From: Art Jack
Subject: running a python script within spss
I have an anaconda python script i'd like to start running but call it from within SPSS. I've attempted to use HOST, & a python subprocess block but am getting an error. My guess is that it's trying to use the python3 within SPSS. I can get the subprocess block to run outside of it. - Thanks Art
------------------------------
Art Jack
------------------------------