Python and IBM SPSS Statistics Working Directories

When running Python code that is within a BEGIN PROGRAM-END PROGRAM block and that contains relative paths in file specifications, you will need to understand the notions of working directories, both for Python and IBM® SPSS® Statistics. You may want to avoid the subtleties involved with working directories by avoiding the use of relative paths and using full paths for file specifications.

  • Relative paths used for file specifications in command syntax submitted from Python (with spss.Submit) are relative to the IBM SPSS Statistics backend working directory. The IBM SPSS Statistics backend working directory determines the full path used for file specifications in command syntax in the case where only a relative path is provided. It can be changed with the CD command, but is not affected by actions involving the file open dialogs, and it is private to the IBM SPSS Statistics backend.
  • Relative paths used when reading and writing files with built-in Python functions--such as open--are relative to the Python current working directory. You can get the Python current working directory from the getcwd function in the os module.