0

I have installed the latest version of IBM SPSS Statistics(Version 26) which has pre installed python 3.4 and 2.7. i am trying to use version 3.4 python. i am able to import modules like pip , sys , os etc. i tried pandas the same way. i am unable to do so. getting error no module found. Hence going through our forum and IBM support did the following changes.

received the following error

enter image description here1) tried pointing the site-packages via

import sys
# Assuming windows and standard python folder here.
sys.path.append(r"D:\Python34\Lib\site-packages")

2) changed the path in the settings of SPSS

settings in SPSS

3) Tried installing pip in the below folder as suggested in the forum but got message i have already installed the updated version.

C:\Program Files\IBM\SPSS\Statistics\Subscription\Python3

4) following versions of python were installed

enter image description here

have tried what i could. Need your expertise help to fix the same which will help me to install/use modules needed for SPSS. Thanks.

Prakash
  • 119
  • 2
  • 9
  • Point your SPSS to the Anaconda folder, and you will have pandas available inside the SPSS environment – horace_vr Apr 11 '20 at 05:24
  • have tried it before reporting it here like appended the path. it did not work either. – Prakash Apr 11 '20 at 14:19
  • Anaconda has pandas, so it should work. I've been using it like that since years ago. Did you restart SPSS after setting it to the Anaconda-python...? You need to set "Other installation of python" as "E:\ProgramData\Anaconda3", then restart SPSS. All modules of Anaconda will be available inside SPSS syntax – horace_vr Apr 11 '20 at 18:16
  • when i try that i get error "Python 3.4 was not found in this location: E:\ProgramData\Anaconda3. Please select a different location, or install Python 3.4 on this computer and set this path again." so i used sitecustomize.py to point anaconda lib site package which did not work either. any other pointers pls. – Prakash Apr 11 '20 at 20:20
  • Fixed it since my ananconda had version 3.7 i created virtual environment and install 2.7 with anaconda package. Pointed SPSS to the 2.7 folder and was able to import pandas. Thanks again for your time and response@horace_vr – Prakash Apr 12 '20 at 00:13

2 Answers2

1

This is going to be painful to explain, I'll do my best.

As far as I can tell, you're on windows. Usually when we need a new package, we just open cmd and type pip install xxx (assume you added python to path when installing it). The reason that this works, is because when you type pip install xxx in cmd, windows recognize pip to be a command because python path is in system variables. Windows know that I can execute pip install with this python path.

However for SPSS python (3.4), that python had a different path in the system. Thus when you only have the 3.7 or 3.8 python in path, windows cannot install package to you 3.4 python, and I'm not sure if you can have more than one python path in system.

In order to fix this, you need to first figure out what's the path to your 3.4 python, then in this page you can follow the instruction to remove your 3.7 or 3.8 python in path, and add your 3.4 path, then you can do pip install xxxx for whatever package you want

I did the same thing with a arcgis python distribution, hope this works for you. If the attached page does not work, just google add python path to windows and look for a instruction that works on you PC

Oh and the reason that you can import pip, sys and some other package but not pandas, is because python is 'battery included', it comes with tons of packages pre-installed for additional functionality, but pandas is not one of them.

Michael Hsi
  • 439
  • 2
  • 8
  • Thanks for your response tried the same no luck let me open a ticket wit IBM and see if they can help – Prakash Apr 11 '20 at 14:18
0

Fixed it since my ananconda had version 3.7 .i created virtual environment and installed 2.7 python with anaconda package. Pointed SPSS to the 2.7 folder and was able to import pandas.

Prakash
  • 119
  • 2
  • 9