xlrd is a module that allows Python to read data from Excel files. This tutorial explains where to get it and how to install it.
Downloading the Python Xlrd Module
- The Python xlrd (short for "Excel Read") module can be found here. After downloading it, you can extract the contents (twice) with 7 Zip.
- Copy the path of the folder that holds "setup.py".
- Note that there's also a Python module for writing MS Excel files. It's called xlwt ("Excel Write") and can be found here.
- The installation process is basically identical to installing xlrd as explained below.
Adding an Environment VariableAdd Python to Path under Environment Variables in Windows
- The installation process is basically identical for Windows 8, Windows 7, Windows Vista and even Windows XP.
- First, right click . Then select .
- At the end of the path, add the path to the folder in which "python.exe" is located. For most SPSS versions this will be something like
;C:\Python27. However, for more recent versions of SPSS, Python is installed in the SPSS installation folder, for example C:\Program Files\IBM\SPSS\Statistics\22\Python
- Confirm by clicking "Ok". At a later step, we'll call Python from the Windows Command Line. This step ensures that
pythonis recognized as an existing application when this is done.
Installing the Python Xlrd Module
Now we'll access the MS Windows Command Prompt. On recent Windows versions, you may need to run the command prompt as an administrator. If you search your programs for
cmd, the command prompt should come up. Right-click it and select "Run as administrator".
Now we'll first set the folder where "setup.py" is located as the default directory, for example by
chdir /D D:\Downloads\xlrd-0.9.2.tar\dist\xlrd-0.9.2\xlrd-0.9.2. Note that the path can be pasted into the window with a right mouse click. All that's now left to do is the actual installation by running
python setup.py install. After doing so, you should be good to go.
THIS TUTORIAL HAS 17 COMMENTS:
By Lisa on December 8th, 2015
Thanks for all the tutorials you put together. I'm having trouble with the last step of running "python setup.py install". This is the error message I get:
'Python' is not recognized as an internal or external command.
I already changed the Path, and I tested that Python is properly installed using your idols.sav file.
By Ruben Geert van den Berg on December 8th, 2015
Thanks for the compliment! This is kinda hard to debug for me but my first guess would be that you didn't add the correct path to the environment variable.
If you're on Windows, try the following: copy the path that you used and press the Windows key + E (opens windows explorer). Now pasting the path into the address bar should open up the folder (path) you specified. On recent SPSS versions, it's probably something like
This folder should contain a file called
python.exe. If that's already the case, then I don't immediately have another suggestion for resolving the problem.
By Mathieu on December 8th, 2015
Hi! Thanks for the tutorials, they are really helpful.
I have trouble installing the xlrd module into SPSS. I think xlrd keeps installing into another program that is using python, and not on SPSS. I have added the path in the Environment Variable and used the Command Prompt, but SPSS keeps telling me that no xlrd module is installed (instead, in the cmd, the path toward the other program is displayed). My OS is Windows 10 and I run SPSS 22. Any insight? Thanks!
By Ruben Geert van den Berg on December 10th, 2015
Thanks for your comment, you're the second person in 3 days reporting such trouble. Perhaps these issues are related to Windows 10?
Honestly, I don't know what's going wrong in your case. The best suggestion I can come up with is to post this issue on SuperUser.com. This is where I get most of my computer issues resolved. If you give it a shot, could you please share with me the URL to the question? It'll (hopefully) allow me to include some more guidelines in my tutorial.
By Mathieu on December 10th, 2015
Thanks for the answer! I tried again after closing my computer and everything as gone well. Thanks for the help (and the interesting tutorials!).