ICS 32 Fall 2017
Project #0: Square One
Installation and Configuration on Windows


Introduction

This document explains how to install the ICS 32 development environment on a machine running the Windows operating system. You'll need to be sure you pay attention to small details as you follow through them; as with many technical tasks, misspelling words, leaving out punctuation, or other seemingly minor mistakes can have fairly major consequences.


Step 1: Show file name extensions

The first step is not to install a software package at all, but to reconfigure a Windows default that is fine for everyday users, but very troublesome for those of us who write programs or do other serious work. By default, when Windows displays a list of filenames (e.g., in File Explorer, Windows Explorer, or on the desktop), it hides the "file name extension" (i.e., the part of the filename that follows the last dot), so that a file named alex.txt will simply have its name displayed as alex instead, with an icon used to visually differentiate one "type" of file from another.

This default is fine for casual users, but is certain to cause us problems in this course — and routinely causes my students problems in courses where there is programming involved — so everyone needs to turn this off, which is easy to do:

Seriously! Do this! You'll be very glad you did; as a programmer, it is important to see filenames as they are.


Step 2: Downloading and installing Python

If you've taken previous coursework in Python, you may already have a version of Python installed on your machine, but it will be important that you use the right version in this course. What you need is Python 3.6.2 64-bit for Windows, which is available at the following link.

Before you run this, it's not a bad idea to uninstall any other version you already have installed. While different versions of Python can safely coexist on a system in some cases, they do cause some confusion, so if you don't have a specific reason to maintain multiple versions, it's easiest to keep just one. You can uninstall Python just as you would any other Windows application (e.g., Add/Remove Programs, Programs and Features, etc., depending on your Windows version).

The file linked above is a standard Windows installer, so you should be able to simply download and run it. The most important question you'll be asked along the way is where you want to install Python; otherwise, accept all defaults. I'd suggest a short installation path of C:\Python36, which may differ from the default that's offered to you, but anything will do, so long as (a) the path does not contain any spaces, and (b) you make a note of what you chose, as you'll need to refer back to that location again. We'll call that location your Python root from now on.


Step 3: Configuring your Python installation

Starting a Command Prompt

Many of you may never have used a Command Prompt in Windows before, but we will have a need for it in this course. Whenever I specify that you should start a Command Prompt on any version of Windows, you can most easily do this by holding down the Windows key and pressing R, which will pop up a dialog asking you what you would like to run. Type cmd into the text field and click OK. (You can also create shortcuts, find it in your Start Menu, or pin it to your taskbar, but cmd will work if you have no other way to do it.)

Understanding the PATH environment variable

A Command Prompt offers a way to navigate the folders on your storage devices (such as your hard drive(s)) manually and run programs and other commands by typing their names. For example, there is a command-line version of the Python interpreter; the program is called python.exe, and you can execute it by simply typing its name (and the .exe is not necessary, so you can just type python). However, you can only run a program from the Command Prompt if Windows can find it. Rather than searching your entire hard drive for the program, it will search only in the places it's been told to search. The PATH environment variable specifies all of the folders that will be searched.

Because we will sometimes need to run Python programs from a Command Prompt, we'll need to configure the PATH environment variable to include a couple of new folders in the search.

Configuring your PATH environment variable

The PATH environment variable is a list of folders, separated by semicolons, in which Windows will look for a program whenever you try to execute one by typing its name at a Command Prompt. You can see the current value of your PATH by typing this command at a Command Prompt:

echo %PATH%

Notice that you'll get back a list of folders separated by semicolons, so you might see something like this — though it will be different, depending on what software you've installed previously. Mine has 20 or so entries, some of which look like this:

C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\

Our goal is to add two new folders to this list, while being sure to remove previously-installed versions of Python from it (if there are any).

The easiest way to permanently change environment variables is to bring up the built-in environment variable editor in Windows. How you get to this editor is slightly different on different versions of Windows.

Once you've brought up the environment variable editor, you'll do something similar regardless of which version of Windows you're running. Under System variables in the bottom half of the editor, find a variable called PATH. If there is is one, select it, click Edit.... Assuming your Python root is C:\Python36, add these two directories to your path:

C:\Python36
C:\Python36\Scripts

How you edit the path is slightly different, depending on which version of Windows you're running.

Also, if you see folders belonging to another Python installation (e.g., C:\Python35), remove them to avoid conflicts. After making your edits, press OK.

If you don't have a PATH environment variable at all, add it by clicking New..., specifying the Variable name as PATH, and adding these two directories to it:

C:\Python36
C:\Python36\Scripts

Testing your Python installation

Now that you've come this far, you should be ready to test your Python installation. Start a Command Prompt and type the command python and hit the Enter key. You should see something more or less like this show up in the Command Prompt window as a result:

Python 3.6.2 (v3.6.2:5fd33b5, Jul  8 2017, 04:57:36) [MSC v.1900 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>

If so, type quit() and press Enter to stop the interpreter, then close the Command Prompt window; you're good to go and are ready to launch IDLE!

If you see a different version — don't worry too much about the date or the funny-looking "5fd33b5" numbering; as long as you see "3.6.2", you're where you need to be — that means you have another version of Python installed and its folder appears earlier in your PATH environment variable than the new one does. If instead you see an error message like this (note that it varies a bit from one version of Windows to another):

'python' is not recognized as an internal or external command,
operable program or batch file.

then the likeliest cause is that you didn't configure your PATH environment variable correctly, so Windows isn't searching for python.exe in the right place.

Starting IDLE

Lastly, you'll want to be sure that you try starting IDLE and verify that it, too, is running the right version of Python. The easiest way to launch IDLE is to find it in your Start Menu — there should be a program group called Python 3.6, in which you'll find a link called IDLE (Python GUI). Click that link; you should see a window pop up, in which will appear the same message you saw when you started Python from the Command Prompt:

Python 3.6.2 (v3.6.2:5fd33b5, Jul  8 2017, 04:57:36) [MSC v.1900 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>

If so, you're ready to roll!


Congratulations!

Nice work! You should now be ready to proceed with your work this quarter. We will likely need additional tools later in the quarter, but this will be sufficient to get started.