Table of contents
- General Instructions to Install Python
- How to install the Python Interpreter on a Windows machine?
- How to use IDLE with files?
- Helpful notes
General Instructions to Install Python
- Go to https://www.python.org/
- Roll over the Downloads link on the top blue bar. You should get a button to download the version for your operating system.
- Be sure to choose the latest Python version that starts with
3.
- The last time these instructions were updated, the most recent version was
- By the time you read this, the current version may be different.
- Double-click the downloaded file to install. Follow all instructions.
Mac users NOTE
At the end of the install, click on Install Certificates to install a set of current SSL root certificates. (See screenshots.)
Mac users: You can click yes when it asks to move the installer to the Trash.
Windows users:
Look carefully for any option to “add Python to PATH” - You DO want to do this — so if a box needs to be checked, check it.
If you need the step-by-step instructions on how to install your very first Python interpreter on a Windows machine, then read on.
Skip to “How to use IDLE with files?” below if you are ready to get started with IDLE.
How to install the Python Interpreter on a Windows machine?
If you have other types of OS (e.g., Linux, Mac), your process can slightly differ from these instructions. Feel free to look it up online or ask us for help during the office hours.
Step 1. Go to python.org
Open your browser and go to https://www.python.org/download
Step 2. Download the latest version
Click on the button “Download Python “ - the specific version can change, so do not worry about it, as long as it is greater than 3.7.
Pressing the “Python ” button will initiate the downloading process for the python installer (python installer !=
python interpreter).
If your browser asks you if you want to download this .exe file - choose “yes”.
If the browser asks you for the place to save this file - choose any folder, it is not important. (We suggest the “Downloads” folder)
Check that you see the process in your browser.
Wait until the file finishes downloading - it might take a few minutes.
Step 3. Find and run the installer
Find it on your computer or in your browser (see the previous picture) and double-click on it to run it.
You should have the result, similar to the picture below. Click “Run”.
Step 4. IMPORTANT!
Add Python to the PATH
IMPORTANT! If you are on a Windows system - make sure that the last checkbox is marked!
Step 5. Install
Press the “Install Now” line.
Wait until the installation process is finished.
Step 6. Celebrate
You should now see the “Setup was Successful” line as shown in the animation above.
Congratulations! You’ve successfully done the installation. Now we learn how to check that the Python interpreter works.
If something went wrong, please seek out help during lab or office hours.
How to use IDLE with files?
Open IDLE on your computer. If you have installed Python - IDLE goes with it in one package.
Warning!
⚠️ IMPORTANT: When IDLE opens, it opens what is called a Python Console - you’ll see “IDLE Shell” or “Python Shell” when you look at the very top of that window.
- If you are seeing
Type "help", "copyright", "credits" or "license()" for more information.
in this window, then you are in the IDLE Python Shell. - DO NOT use the IDLE/Python Shell to write the code for this class.
- INSTEAD use the “New File” to open a new window when you want to write code (as explained below)
Here’s why:
- When you create a new file, your code will be saved on your computer and can be re-run easily.
- Code you type into the IDLE Shell is intended for quick experiments; it cannot be saved in a way that it can be re-run easily.
Create a new Python file in IDLE
Use “File” -> “New File”
to create a new file or “File” -> “Open”
to open one that you previously created.
Remember to save your work somewhere you can find it. (We recommend creating a dedicated folder for your code.)
When you are in the file-editing window, you can use “Run” -> “Run Module”
to run this specific file as a script and see your code in action.
⚠️ If you are not seeing the top menu "Run"
, then you are not in the file-editing window.
Running a file that asks for user input
Note! If your program requires input you will need to provide it inside the Python console, which will be displaying the output of your program/script!
Python will put the cursor and wait until you give the input to it. It won’t run your program or give you any hints that it is waiting for something. Be careful with inputs!
Helpful notes
Enable line numbers
In IDLE, you can select the "Show Line Numbers"
option from the top "Options"
menu. Seeing line numbers helps a lot with debugging, since Python errors report the code’s line number where the error was detected.
Force the program to stop
If you want to stop the program that behaves unexpectedly or runs for too long - just press Ctrl+C
(Control
and C
at the same time) and the program will stop with the “Keyboard stopped me” Error (KeyboardInterrupt
).
Function prompts
If, in IDLE file mode, you write the name of a function, type an open parenthesis (
and wait a little, you will get a help prompt that shows you how to use this function.
We hope that this is helpful 👍. If you have any follow-up questions 🧐 or comments, we look forward to addressing them on the forum.
Have a productive week!
Acknowledgements
- Specials thanks to Liubov Kurafeeva and Roman Beltiukov for creating the initial instructions and screenshots.
Updated W23 by P. Conrad
- General instructions were adopted from https://python-adv-web-apps.readthedocs.io/en/latest/.