This page walks through how to install a version of Python on Windows that is compatible with this tutorial.
Any version of Python 3 will work for this tutorial. If you don't have Python installed, we'll install Python version 3.4.1.
If you already have Python installed, check the Python version: if the version number starts with a 3 (as opposed to a 2), you can use it for this class and can skip to setting your Path.
- Click https://www.python.org/ftp/python/3.4.1/python-3.4.1.msi and choose "run" if you have the option to. Otherwise, save it to your Desktop, then minimize windows to see your desktop, and double click on it to start the installer. Follow the installer instructions to completion.
- Open a terminal (we will be doing this multiple times, so make a note of how to do this!):
- On Windows 10: click on the Start menu (the Windows logo in the lower left of the screen), and type
cmd
. Click on the "Command Prompt" search result. - On Windows Vista or Windows 7: click on the Start menu (the Windows logo in the lower left of the screen), type
cmd
into the Search field directly above the Start menu button, and click on "cmd" in the search results above the Search field. - On Windows XP: click on the Start menu (the Windows logo in the lower left of the screen), click on "Run...", type
cmd
into the text box, and hit enter.
You have started a terminal prompt. This terminal prompt is another way of navigating your computer and running programs -- just textually instead of graphically. We are going to be running Python and Python scripts from this terminal prompt. - On Windows 10: click on the Start menu (the Windows logo in the lower left of the screen), and type
- At this
C:\
prompt that appears, test your Python installation by typing:\Python34\python.exe
and pressing Enter. You should see something like
Python 3.4.1 (v3.4.1:d047928ae3f6, May 13 2013, 12:45:22) on win32 Type "help", "copyright", "credits" or "license" for more information. >>>
You just started Python! The
>>>
indicates that you are at a new type of prompt -- a Python prompt. The terminal prompt lets you navigate your computer and run programs, and the Python prompt lets you write and run Python code interactively. - To exit the Python prompt, type
exit()
and press Enter. This will take you back to the Windows command prompt (the
C:\
you saw earlier).
You might have noticed that you typed a "full path" to the Python application above when launching Python (python.exe
is the application, but we typed \Python34\python.exe
). In this step, you will configure your computer so that you can run Python without typing the ''Python34'' directory name.
-
Right-click on the Start menu. Click the "System" entry. This will pop up a window that says "View basic information about your computer".
-
Click the "Advanced system settings" link in the left panel. This will pop up a System Properties window.
-
Click the "Environment Variables..." button. This will pop up an Environment Variables window.
-
Select the "PATH" variable and press the "Edit..." button.
-
Add the following entries for the PATH environment variable:
C:\Python34
C:\Python34\Scripts
- Open up "My Computer" by clicking on the Start menu or the Windows logo in the lower-left hand corner, and navigate to "My Computer" (for Windows XP) or "Computer" (For Vista and Windows 7).
- ''Right-click'' on the empty space in the window, and choose ''Properties''.
A window labeled "System Properties" will pop up.
- Click the "Advanced" tab.
A window labeled "View basic information about your computer" will appear.
- In this window, click "Advanced system settings"
A window with the title "System Properties" will appear.
- Within System Properties, make sure you are in the tab labeled "Advanced".
- Click the button labeled "Environment Variables". A window labeled "Environment Variables" will appear.
- In this window, the screen is split between "User variables" and "System variables". Within "System variables", scroll down and find the one labeled '''Path'''. Click the "Edit..." button.
A window with the "Variable name" and the "Variable value" should appear. The "Variable value" will already have some text in it; click in the box to unhighlight it (we don't want to accidentally delete that text).
- In the "Variable value" box, scroll to the end. Add the following text, and hit OK. Make sure to include the semicolon at the start!
;c:\python34\;c:\python34\scripts
- Press "OK" to close out the system properties window.
To test your change:
- Open up a new command prompt: do this the same way you did above when installing Python. This needs to be a new command prompt because the changes you just made didn't take effect in prompts that were already open.
- Type
python
into the command prompt and press return to start Python - Notice that you now get a Python interpreter, indicated by the change to a
>>>
prompt. - Exit the Python prompt by typing
exit()
and hitting enter. Now you're back at the Windows command prompt (C:\
).
You have Python installed, configured, and tested.
Questions? Please don't hesitate to reach out to the author (me, Jessica!) at:
[email protected]
.