ICS 32 Winter 2022
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.10.1 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:\Python310, 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.

When you run the Windows installer, you'll also want to be sure you've checked the box asking the installer to "Add Python to PATH", which turns out to be important later in the course.


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.

If you asked the Python installer to add Python to your PATH environment variable, then you won't need to do anything here, but you should at least verify that it's working. Start a Command Prompt, then type the command python, followed by the Enter key. If you see what looks like a Python shell, you're in business; type quit() and press the Enter key to exit the shell, and you're off and running.

Configuring your PATH environment variable manually

If you've discovered that your PATH environment variable is not configured, then you'll want to configure it now.

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:\Python310, add these two directories to your path:

C:\Python310
C:\Python310\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:\Python36), 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:\Python310
C:\Python310\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.10.1 (tags/v3.10.1:2cd268a, Dec  6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "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 "2cd268a" numbering; as long as you see "3.10.1", 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.9, 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.10.1 (tags/v3.10.1:2cd268a, Dec  6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)] on win32Type "help", "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.