SPSS Statistics

SPSS Statistics

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

 View Only
  • 1.  pip3 install openpyxl

    Posted Tue December 19, 2023 01:09 PM

    Hi,

    I am trying to use openpyxl with SPSS 26. It looks like the openpyxl is installed on the Python 3.4 which is installed with SPSS. The code I am running from SPSS is the following.

    begin program python3.
    import openpyxl
    end program.

    But getting the following error.

    Traceback (most recent call last): 
      File "<string>", line 2, in <module> 
    ImportError: No module named 'openpyxl'

    Can anyone please help me with it?

    With thanks,

    Zula



    ------------------------------
    Zula
    ------------------------------


  • 2.  RE: pip3 install openpyxl

    Posted Tue December 19, 2023 02:08 PM
    Check the path locations set for Python in that version.
    begin program python3.
    import sys
    print(sys.path)
    end program.

    oprnpyxl should be in one of those locations, or at least the openpyxl directory.

    You  might try installing it via the STATS INSTALL PACKAGES extension command, which should ensure that it is in a location where SPSS Statistics will use.

    STATS INSTALL PACKAGES can be installed via Extensions > Extension Hub if you don't already have it.

    --





  • 3.  RE: pip3 install openpyxl

    Posted Tue December 19, 2023 02:46 PM
    Hi Jon,

    Nice to get in touch with you again. 

    With your help, I see that there is no 'openpyxl' folder in the C:\Program Files\IBM\SPSS\Statistics\26\Python3\Lib\site-packages, but when I try 'pip install openpyxl' command in this location, I am getting the following error. When try 'pip install imp', still getting same error, so any idea?

    C:\Program Files\IBM\SPSS\Statistics\26\Python3\Lib\site-packages>pip install openpyxl
    Traceback (most recent call last):
      File "<frozen runpy>", line 189, in _run_module_as_main
      File "<frozen runpy>", line 148, in _get_module_details
      File "<frozen runpy>", line 112, in _get_module_details
      File "C:\Program Files\IBM\SPSS\Statistics\26\Python3\Lib\site-packages\pip\__init__.py", line 13, in <module>
        from pip.utils import get_installed_distributions, get_prog
      File "C:\Program Files\IBM\SPSS\Statistics\26\Python3\Lib\site-packages\pip\utils\__init__.py", line 17, in <module>
        from pip.compat import console_to_str, stdlib_pkgs
      File "C:\Program Files\IBM\SPSS\Statistics\26\Python3\Lib\site-packages\pip\compat\__init__.py", line 6, in <module>
        import imp
    ModuleNotFoundError: No module named 'imp'

    Re using STATS INSTALL PACKAGES, somehow the Extension hub window is not opening for me. When clicked, the window appears very briefly then disappears.

    With thanks,
    Zula





  • 4.  RE: pip3 install openpyxl

    Posted Tue December 19, 2023 03:06 PM
    This looks like more than I can diagnose, but you might try running pip not from site-packages but from the scripts folder under Python.  It's a long shot, though.--