1

I need to be able to run JupyterLab on the Python executable in SPSS in order to import some SPSS libraries (spss, spssaux, SpssClient, etc.) in a notebook in JuptyerLab. Based on answers to other Ancadonda/executable-related questions, I've attempted two possible solutions:

  1. Paste the relevant libraries from the Python directory in SPSS to the Python directory in Anaconda. I tried this both to the base environment and to the virtual environment I work out of, and tried launching JupyterLab both from the base and from the virtual environment. I copied the files from C:\Program Files\IBM\SPSS\Statistics\27\Python3\Lib\site-packages to C:\ProgramData\Anaconda3\Lib.

  2. Redirect Anaconda to the Python executable in SPSS. I tried to to do that with sys.path.insert:

import sys

sys.path.insert(0, 'C:\Program Files\IBM\SPSS\Statistics\27\Python3')

Attempt #1 results in the following error when I try to import spss:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_11344/2864419669.py in <module>
----> 1 import spss

C:\Program Files\IBM\SPSS\Statistics\27\Python3\Lib\site-packages\spss\__init__.py in <module>
    254 __SetErrorMessage()
    255 
--> 256 from .spss import *
    257 from .cursors import *
    258 from .pivotTable import *

C:\Program Files\IBM\SPSS\Statistics\27\Python3\Lib\site-packages\spss\spss.py in <module>
     21 
     22 import atexit,os,locale,sys,codecs
---> 23 from . import PyInvokeSpss
     24 from .errMsg import *
     25 

ImportError: DLL load failed while importing PyInvokeSpss: The specified module could not be found.

This in spite of having copied PyInvokeSpss to C:\ProgramData\Anaconda3\Lib.

#2 doesn't seem to change the path to the executable:

C:\ProgramData\Anaconda3\python.exe
  1. I also have an idea for a third solution, which would be to package the Python that's in SPSS as an iPython kernel, and then activate that in JupyterLab after it's launched, but I can't figure out a way of doing that.

What's the best direction here for a solution? What am I doing wrong?

semblable
  • 773
  • 1
  • 8
  • 26

0 Answers0