CMU 15-110: Principles of Computing
Installing Python and Pyzo
Note: Your TA's will be happy to help with any of these steps!
- Install Python3
Download and install Python 3.6 or later from python.org's download page. - Run IDLE (the default Python text editor / IDE)
Everyone should use Pyzo at least for the first month of this course. However, since IDLE is available without extra installs in nearly all Python installations (including the cluster machines at CMU), you should also know about and be able to use IDLE. In most cases, you can type IDLE into your Mac or Windows search and it will find and run it. - Run Pyzo (formerly "IEP")
Pyzo is a new Python IDE that is easy to setup and use. It has some nice features that IDLE does not, such as line numbers (which are a big deal, actually), an 80-character line (very handy), and so on. Everyone in 15-110 will use Pyzo at least for the first 4 weeks of the semester. To install pyzo:- Download and install Pyzo from the appropriate link:
- Pyzo for Windows
- Pyzo for OS X
Note: drag the icon to your Applications folder. You may also need to control-click to Open the first time only, to approve launching this downloaded app. - Pyzo for Linux
- Launch Pyzo.
- Setup your shell configuration for Python 3
- On the top menu, click Shell->Edit Shell Configurations
- Click the dropdown labeled exe, and choose Python 3.6 (or later)
- Under "gui", select "None no gui support" (otherwise you may have problems when we do graphics).
- Press done.
- Restart Pyzo and you're ready to go!
- Go to http://retinizer.mikelpr.com/, and download the app 'Retinizer'.
- Install 'Retinizer'. (It is from the Apple Store, so in order to open it, you may first either control-click on it and select "Open", or go to 'System Preference', 'Security & Privacy', 'General' and 'Allow apps download from', 'Anywhere'.)
- Open 'Retinizer', drag pyzo from your 'Applications' folder to 'Retinizer', press Retinize!
- Reopen pyzo and the resolution should be adjusted to fit a Retina display!
- Close the extra frames (file browser, etc), only use editor frame (on top, where it is by default) and shell frame (which you should drag to the bottom), so it mirrors IDLE's simple setup.
- Relaunch Pyzo, for a simple Python3 test, use this program: print(5/3), then choose Run File as Script or Execute File from the Run menu. You should not get 1 (which you would get if you are using Python2) but instead should get 1.666666667.
- Download and install Pyzo from the appropriate link:
- Edit your Python file
In Pyzo, you need to open a Python file or create a new Python file, which then places you in the editing window. That is where you write your code. Be sure to save your code in a file ending in .py (like: foo.py) before running it! - Run your code
Each IDE has its own way to run code. In Pyzo, from the "Run" menu, select "Run file as script". This loads and runs your code in the Python Shell (the interpreter that runs Python code, instead of editing it).- There are several options on the Run menu. Be sure to use the first one, "Run file as script".
- Some students reported an error where Pyzo could not find files that are imported from the same folder as the main file. In these cases, this was remedied (if not outright fixed) by going into Shell/Edit-Shell-Configurations and setting the startDir field either to "." (just a dot, no quotes) or, in some cases, to the full path where your main file is.