SPSS Statistics

SPSS Statistics

Your hub for statistical analysis, data management, and data documentation. Connect, learn, and share with your peers! 


#Analytics
#SPSSStatistics
#Analyticstools
 View Only
Expand all | Collapse all

DYLD_LIBRARY_PATH

  • 1.  DYLD_LIBRARY_PATH

    Posted 11/08/22 03:56 PM
    Hi.

    I am attempting to run Statistics from an external Python process. I am following the instructions in the 'Python Reference Guide for IBM SPSS Statistics', p. 10 - 11.
    I am using Statistics 28 and macOS Big Sur (11.6.4).

    I worked through the sitecustomize.py part and from my external Python IDE (VS Code) I now can

    spss.StartSPSS()
    spss.Submit("DISPLAY NAMES.")

    successfully, i.e. resulting in the expected output.


    However, I am in trouble with the export DYLD_LIBRARY_PATH ... part.
    After substituting the <SPSS_HOME> placeholders with I get

    export DYLD_LIBRARY_PATH=/Applications/IBM SPSS Statistics/SPSS Statistics.app/Contents/lib:/Applications/IBM SPSS Statistics/SPSS Statistics.app/Contents/Library/Frameworks/Sentinel.framework/Versions/A:/Applications/IBM SPSS Statistics/SPSS Statistics.app/Contents/Library/Frameworks/SuperPro.framework/Versions/A

    Running this gives me

    bash-3.2$  export DYLD_LIBRARY_PATH=/Applications/IBM SPSS Statistics/SPSS Statistics.app/Contents/lib:/Applications/IBM SPSS Statistics/SPSS Statistics.app/Contents/Library/Frameworks/Sentinel.framework/Versions/A:/Applications/IBM SPSS Statistics/SPSS Statistics.app/Contents/Library/Frameworks/SuperPro.framework/Versions/A
    bash: export: `Statistics/SPSS': not a valid identifier
    bash: export: `Statistics.app/Contents/lib:/Applications/IBM': not a valid identifier
    bash: export: `Statistics/SPSS': not a valid identifier
    bash: export: `Statistics.app/Contents/Library/Frameworks/Sentinel.framework/Versions/A:/Applications/IBM': not a valid identifier
    bash: export: `Statistics/SPSS': not a valid identifier
    bash: export: `Statistics.app/Contents/Library/Frameworks/SuperPro.framework/Versions/A': not a valid identifier

    I then tried

    bash-3.2$ DYLD_LIBRARY_PATH='/Applications/IBM SPSS Statistics/SPSS Statistics.app/Contents/lib:/Applications/IBM SPSS Statistics/SPSS Statistics.app/Contents/Library/Frameworks/Sentinel.framework/Versions/A:/Applications/IBM SPSS Statistics/SPSS Statistics.app/Contents/Library/Frameworks/SuperPro.framework/Versions/A'
    bash-3.2$ export DYLD_LIBRARY_PATH
    bash-3.2$ export PYTHONHOME=/Users/fw/Library/Python/3.9

    resulting in 

    bash-3.2$ export
    declare -x DISPLAY="/private/tmp/com.apple.launchd.snpo2Q1k9I/org.xquartz:0"
    declare -x DYLD_LIBRARY_PATH="/Applications/IBM SPSS Statistics/SPSS Statistics.app/Contents/lib:/Applications/IBM SPSS Statistics/SPSS Statistics.app/Contents/Library/Frameworks/Sentinel.framework/Versions/A:/Applications/IBM SPSS Statistics/SPSS Statistics.app/Contents/Library/Frameworks/SuperPro.framework/Versions/A"
    declare -x HOME="/Users/fw"
    declare -x LANG="de_DE.UTF-8"
    declare -x LOGNAME="fw"
    declare -x OLDPWD
    declare -x PATH="/Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin"
    declare -x PWD="/Users/fw"
    declare -x PYTHONHOME="/Users/fw/Library/Python/3.9"
    declare -x SHELL="/bin/zsh"
    declare -x SHLVL="2"
    declare -x SPSS
    declare -x SSH_AUTH_SOCK="/private/tmp/com.apple.launchd.bu9pPnVBGw/Listeners"
    declare -x TERM="xterm-256color"
    declare -x TERM_PROGRAM="Apple_Terminal"
    declare -x TERM_PROGRAM_VERSION="440"
    declare -x TERM_SESSION_ID="627A98D7-EC1D-4EEB-9DB7-BC4F208B5A7C"
    declare -x TMPDIR="/var/folders/q2/_nc06thn4g53wvw1x3xy_mr00000gn/T/"
    declare -x USER="fw"
    declare -x XPC_FLAGS="0x0"
    declare -x XPC_SERVICE_NAME="0"
    declare -x __CFBundleIdentifier="com.apple.Terminal"


    Running (from VS Code)

    import SpssClient
    SpssClient.StartClient()

    now returns

    fw@fwiMac Desktop % /usr/local/bin/python3 /Users/fw/Desktop/runspss.py
    Traceback (most recent call last):
      File "/Users/fw/Desktop/runspss.py", line 1, in <module>
        import SpssClient
      File "/Applications/IBM SPSS Statistics/Resources/Python3/lib/python3.9/site-packages/SpssClient/__init__.py", line 63, in <module>
        tempPath = os.pathsep.join([spssclient_home, jvmlibpath, spsslibpath, os.getenv("DYLD_LIBRARY_PATH")])
    TypeError: sequence item 3: expected str instance, NoneType found
    fw@fwiMac Desktop % 

    I understand the culprit is os.getenv("DYLD_LIBRARY_PATH").
    But what can I do in order to fix this?

    #SPSSStatistics


  • 2.  RE: DYLD_LIBRARY_PATH

    Posted 11/08/22 04:09 PM
    Hi.

    Does setting off the paths with quotes help? The export isn't going to like spaces in path names that are not set off with quotes, I think.

    For example:

    export DYLD_LIBRARY_PATH='/Applications/IBM SPSS Statistics/SPSS Statistics.app/Contents/lib':'/Applications/IBM SPSS Statistics/SPSS Statistics.app/Contents/Library/Frameworks/Sentinel.framework/Versions/A':'/Applications/IBM SPSS Statistics/SPSS Statistics.app/Contents/Library/Frameworks/SuperPro.framework/Versions/A'

    Backslashes might also work, to show the OS that the spaces in the path names are literals.


    ------------------------------
    Rick Marcantonio
    Quality Assurance
    IBM
    ------------------------------



  • 3.  RE: DYLD_LIBRARY_PATH

    Posted 11/08/22 04:19 PM
    Thanks, Rick. 
    The extra quotes apparently don't survive and SpssClient.StartClient() won't succeed.

    fw@fwiMac Desktop % export DYLD_LIBRARY_PATH='/Applications/IBM SPSS Statistics/SPSS Statistics.app/Contents/lib':'/Applications/IBM SPSS Statistics/SPSS Statistics.app/Contents/Library/Frameworks/Sentinel.framework/Versions/A':'/Applications/IBM SPSS Statistics/SPSS Statistics.app/Contents/Library/Frameworks/SuperPro.framework/Versions/A'
    fw@fwiMac Desktop % export
    COLORTERM=truecolor
    COMMAND_MODE=unix2003
    DISPLAY=/private/tmp/com.apple.launchd.snpo2Q1k9I/org.xquartz:0
    DYLD_LIBRARY_PATH='/Applications/IBM SPSS Statistics/SPSS Statistics.app/Contents/lib:/Applications/IBM SPSS Statistics/SPSS Statistics.app/Contents/Library/Frameworks/Sentinel.framework/Versions/A:/Applications/IBM SPSS Statistics/SPSS Statistics.app/Contents/Library/Frameworks/SuperPro.framework/Versions/A'
    GIT_ASKPASS='/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/git/dist/askpass.sh'
    HOME=/Users/fw
    LANG=en_US.UTF-8
    LOGNAME=fw
    MallocNanoZone=0
    OLDPWD=/Users/fw/Desktop
    ORIGINAL_XDG_CURRENT_DESKTOP=undefined
    PATH=/Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/Library/Frameworks/Python.framework/Versions/3.10/bin
    PWD=/Users/fw/Desktop
    SHELL=/bin/zsh
    SHLVL=1
    SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.bu9pPnVBGw/Listeners
    TERM=xterm-256color
    TERM_PROGRAM=vscode
    TERM_PROGRAM_VERSION=1.73.0
    TMPDIR=/var/folders/q2/_nc06thn4g53wvw1x3xy_mr00000gn/T/
    USER=fw
    USER_ZDOTDIR=/Users/fw
    VSCODE_GIT_ASKPASS_EXTRA_ARGS=--ms-enable-electron-run-as-node
    VSCODE_GIT_ASKPASS_MAIN='/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/git/dist/askpass-main.js'
    VSCODE_GIT_ASKPASS_NODE='/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper'
    VSCODE_GIT_IPC_HANDLE=/var/folders/q2/_nc06thn4g53wvw1x3xy_mr00000gn/T/vscode-git-243f6960a8.sock
    VSCODE_INJECTION=1
    XPC_FLAGS=0x0
    XPC_SERVICE_NAME=application.com.microsoft.VSCode.12928313452.12928313458
    ZDOTDIR=/Users/fw
    __CFBundleIdentifier=com.microsoft.VSCode
    __CF_USER_TEXT_ENCODING=0x1F5:0x0:0x3








  • 4.  RE: DYLD_LIBRARY_PATH

    Posted 11/09/22 11:51 AM
    I have asked various colleagues. One suggested the export statement:
    export DYLD_LIBRARY_PATH=/Applications/IBM\ SPSS\ Statistics/SPSS\ Statistics.app/Contents/lib:/Applications/IBM\ SPSS\ Statistics/SPSS\ Statistics.app/Contents/Library/Frameworks/Sentinel.framework/Versions/A:/Applications/IBM\ SPSS\ Statistics/SPSS\ Statistics.app/Contents/Library/Frameworks/SuperPro.framework/Versions/A

    Another said that in his opinion, the DYLD_LIBRARY_PATH was not the real problem; rather, spssxdcfg.ini has an empty setting for spssxd_path. He didn't, and I don't, know exactly what that setting should be. (The original developers of this feature are not available at the moment, or I would have consulted them.) 

    ------------------------------
    Rick Marcantonio
    Quality Assurance
    IBM
    ------------------------------



  • 5.  RE: DYLD_LIBRARY_PATH

    Posted 11/09/22 11:54 AM
    Additionally, a colleague told me that the references to SPSS Statistics.app/Contents/Library/Frameworks/Sentinel.framework and SuperPro.framework are not needed in the DYLD_LIBRARY_PATH statement, because they are no longer included in our program.

    ------------------------------
    Rick Marcantonio
    Quality Assurance
    IBM
    ------------------------------



  • 6.  RE: DYLD_LIBRARY_PATH

    Posted 11/09/22 01:42 PM
    I only use Windows, but I expect that that environment variable is not needed.  You could create and export an empty string if there is some left over code that refers to it.
    --





  • 7.  RE: DYLD_LIBRARY_PATH

    Posted 11/09/22 05:26 PM

    No luck yet, but I seem to be getting closer. 

    I realized that I had had multiple Python installations on my system. I have since deleted all of them and reinstalled Python 3.11 into my user library.

    In this Python 3.11 installation, I set up sitecustomize.py again. I also set the environment variables DYLD_LIBRARY_PATH and PYTHONHOME again as instructed.

    With these two environment variables set, I get a Fatal Python error as follows:

    fw@fwiMac ~ % export DYLD_LIBRARY_PATH=/Applications/IBM\ SPSS\ Statistics/SPSS\ Statistics.app/Contents/lib:
    fw@fwiMac ~ % export PYTHONHOME=/Users/fw/Library/Python/3.11
    fw@fwiMac ~ % python3
    Python path configuration:
      PYTHONHOME = '/Users/fw/Library/Python/3.11'
      PYTHONPATH = (not set)
      program name = '/Library/Frameworks/Python.framework/Versions/3.11/Resources/Python.app/Contents/MacOS/Python'
      isolated = 0
      environment = 1
      user site = 1
      safe_path = 0
      import site = 1
      is in build tree = 0
      stdlib dir = '/Users/fw/Library/Python/3.11/lib/python3.11'
      sys._base_executable = '/Library/Frameworks/Python.framework/Versions/3.11/bin/python3.11'
      sys.base_prefix = '/Users/fw/Library/Python/3.11'
      sys.base_exec_prefix = '/Users/fw/Library/Python/3.11'
      sys.platlibdir = 'lib'
      sys.executable = '/usr/local/bin/python3'
      sys.prefix = '/Users/fw/Library/Python/3.11'
      sys.exec_prefix = '/Users/fw/Library/Python/3.11'
      sys.path = [
        '/Users/fw/Library/Python/3.11/lib/python311.zip',
        '/Users/fw/Library/Python/3.11/lib/python3.11',
        '/Users/fw/Library/Python/3.11/lib/python3.11/lib-dynload',
      ]
    Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
    Python runtime state: core initialized
    ModuleNotFoundError: No module named 'encodings'

    Current thread 0x000000010ae09e00 (most recent call first):
      <no Python frame>
    After unsetting PYTHONHOME 

    fw@fwiMac ~ % quit()
    function> bash
    fw@fwiMac ~ % unset PYTHONHOME

    Python at least talks to me again:


    fw@fwiMac ~ % python3
    Python 3.11.0 (v3.11.0:deaf509e8f, Oct 24 2022, 14:43:23) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import spss
    >>> import SpssClient
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/Applications/IBM SPSS Statistics/Resources/Python3/lib/python3.9/site-packages/SpssClient/__init__.py", line 89, in <module>
        from ._SpssClient import *
    ImportError: dlopen(/Applications/IBM SPSS Statistics/Resources/Python3/lib/python3.9/site-packages/SpssClient/_SpssClient.so, 2): Library not loaded: @rpath/libpython3.9.dylib
      Referenced from: /Applications/IBM SPSS Statistics/Resources/Python3/lib/python3.9/site-packages/SpssClient/_SpssClient.so
      Reason: image not found
    >>> 


    All of the above was run in a single terminal session. After replicating the steps in VS Code, its code completion feature indicated that SpssClient is accessible:


    However, the execution of the code produced the same results as in the terminal.

    Does this give any clues for further troubleshooting?







  • 8.  RE: DYLD_LIBRARY_PATH

    Posted 11/09/22 06:25 PM
    Well, one thing is that with Statistics V29, the supported Python version is 3.10, not 3.11.  I don't know how that plays into this story, though.

    --





  • 9.  RE: DYLD_LIBRARY_PATH

    Posted 11/10/22 09:06 AM
    From a developer:

    "Trying to mix Python 3.11 with Python 3.9 may not work.

    "To find the library in question below, the user needs to add more to their DYLD_LIBRARY_PATH env variable. The library in question is in "/Applications/IBM\ SPSS\ Statistics/Resources/Python3/lib", so I would add that at a minimum, and more also may be needed there. Separate paths in the DYLD_LIBRARY_PATH variable with colons ( : ) on MacOS."



    ------------------------------
    Rick Marcantonio
    Quality Assurance
    IBM
    ------------------------------



  • 10.  RE: DYLD_LIBRARY_PATH

    Posted 11/10/22 12:08 PM
    An addendum from the same developer:

    "Since they aren't using the default Python that we ship, they must ensure that any requirements are also installed:

    pip install encodings

    Also see this:
    https://faun.dev/c/stories/faizalm47194738/no-module-named-encodings-a-common-import-error-found-in-python-3/

    In the last resort, have them reset their virtual environment. For example (paths not correct):

    rm -rf venv
    virtualenv -p /usr/bin/python3 venv/
    source venv/bin/activate
    pip install -r requirements.txt"

    ------------------------------
    Rick Marcantonio
    Quality Assurance
    IBM
    ------------------------------



  • 11.  RE: DYLD_LIBRARY_PATH

    Posted 11/10/22 12:38 PM
    The encodings module is included in the standard Python library, so it should not need a separate install.  It is actually a direct ory with a set of modules representing the supported encodings.

    --





  • 12.  RE: DYLD_LIBRARY_PATH

    Posted 11/10/22 05:25 PM
    I im using Statistics V 28 and I switched to python 3.9 (3.9.15, to be precise), as indicated in the Python Reference Guide for V 28.
    Also, I added "/Applications/IBM\ SPSS\ Statistics/Resources/Python3/lib" to DYLD_LIBRARY_PATH:

    export DYLD_LIBRARY_PATH=/Applications/IBM\ SPSS\ Statistics/SPSS\ Statistics.app/Contents/lib:Applications/IBM\ SPSS\ Statistics/Resources/Python3/lib:/Applications/IBM\ SPSS\ Statistics/Resources/Python3/lib/python3.9/encodings

    (The „...encodings..." part shouldn't hurt, I guess - even if it may be redundant.)

    with this DYLD_LIBRARY_PATH being set, running import SpssClient gave me

    Traceback (most recent call last):
      File "/Users/fw/Dropbox/Studium/MSc_Psy/MM8_Masterarbeit/55_vor Analyse/20_Sprachaufbereitung/10_Syntax/Py/del.py", line 2, in <module>
        import SpssClient
      File "/Applications/IBM SPSS Statistics/Resources/Python3/lib/python3.9/site-packages/SpssClient/__init__.py", line 89, in <module>
        from ._SpssClient import *
    ImportError: dlopen(/Applications/IBM SPSS Statistics/Resources/Python3/lib/python3.9/site-packages/SpssClient/_SpssClient.so, 2): Library not loaded: @rpath/libjli.dylib
      Referenced from: /Applications/IBM SPSS Statistics/SPSS Statistics.app/Contents/lib/libJCAdaptorForPython3.dylib
      Reason: image not found

    I found libjli.dylib in the application bundle at "/Applications/IBM\ SPSS\ Statistics/SPSS\ Statistics.app/Contents/JRE/lib/jli", hence I confidently tried

    export DYLD_LIBRARY_PATH=/Applications/IBM\ SPSS\ Statistics/SPSS\ Statistics.app/Contents/lib:Applications/IBM\ SPSS\ Statistics/Resources/Python3/lib:/Applications/IBM\ SPSS\ Statistics/Resources/Python3/lib/python3.9/encodings:/Applications/IBM\ SPSS\ Statistics/Resources/Python3/lib:/Applications/IBM\ SPSS\ Statistics/SPSS\ Statistics.app/Contents/JRE/lib/jli

    Now, import SpssClient gives me

    zsh: segmentation fault  /usr/local/bin/python3 

    or, when using bash:

    Segmentation fault: 11

    How should I proceed from here? Is my updated export statement adequately addressing the new ImportError?

    (Because resetting virtual environments has been mentioned: I don't use virtual environments, but (for now) just the plain on disk installation.)