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
Python path configuration:
PYTHONHOME = '/Users/fw/Library/Python/3.11'
program name = '/Library/Frameworks/Python.framework/Versions/3.11/Resources/Python.app/Contents/MacOS/Python'
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.executable = '/usr/local/bin/python3'
sys.prefix = '/Users/fw/Library/Python/3.11'
sys.exec_prefix = '/Users/fw/Library/Python/3.11'
'/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):
After unsetting PYTHONHOME
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?