CS 1110: Introduction to Computing Using Python
Times & Places
Python and Komodo Edit in CS 1110
Python comes in different versions by different makers for different operating systems. To make sure that everything works as we (and our grading programs) expect, we require that all students use the same major version of Python: ActiveState's ActivePython 2.7.x appropriate to your computer, where the "x" stands for any number (10 or higher for Macs). This applies even if you already have some other Python on your computer.
The computers in the lab rooms already have the required version, so you may use those computers for your coursework. If this is your choice, you need read no further!
Otherwise, please note: software setup can be frustrating, even for the experienced. Like giving birth, it can involve potential pain and bewilderment that is completely NOT representative of the next few months! If you have a laptop that you're having installation trouble with, best is to see any of the course staff, who'll be happy to help. Or, post questions to the course Piazza page.
Instructions in grey are footnotes giving more detail for some special situations or answers to questions some but not all students might have.
Table of Contents
1. Installing ActivePython
1.W: Installing ActivePython on Windows
Supported Platforms: Windows 7, 8, 10. If your operating system is Vista or XP, then you will need to either upgrade or use the machines in the ACCEL lab.
This installation process will put Python in the directory
Click this button:
which still start the download of the installer we want you to use. (Namely, the 32 bit Community Edition of Python 126.96.36.199. Yes, use it even if you have a 64 bit version of Windows, because we need the 32 bit version for compatibility with our add-ons, later.
The file that you download is an MSI installer. Right-click on it instead of the usual double-click. If you are asked to choose between "Run as administrator" or something about running just for yourself or for a single user, choose "Run as administrator"; but you might not be asked. Running as administrator adds
Reboot your computer to ensure that your system updates its information about the location of ActivePython.
1.M: Installing ActivePython on a Mac
Supported Platforms: 10.9 (Mavericks), 10.10 (Yosemite), 10.11 (El Capitan). If you are using an older version of OS X, you will need to either upgrade or use the machines in the ACCEL lab. If you are unsure what version of OS X you are using, go to the Apple menu and select About This Mac. You will see a pop-up dialog that, among other things, lists a Version Number (e.g., "Version 10.10.4").
This installation process will put Python in the directory /Library/Frameworks/Python.framework/Versions/2.7/bin/python and create a "symbolic link" /usr/local/bin/python. If you already have files there (which could happen if you installed another Python before taking this class), unfortunately, the older one will be deleted. ActivePython has its advantages, but it is stubborn about its location.
Click this button:
which still start the download of the installer we want you to use.
The file that you download is a DMG. Double-click on it and it will turn into a virtual disk drive containing a package installer (a icon that looks like an open cardboard box). Control-click on the "cardboard box" instead of the usual double-click, select "Open", and in the next dialog box, also click "Open". The control-click operation circumvents the issue that Mac OS may complain about packages from unidentified developers.
If you have any command shell windows already open, these "old" windows will not "know" where to find ActiveState Python. The easiest way to deal with this is to reboot your computer, so all the windows become "new".
1.L: Installing ActivePython on Linux
Click on one of the two following links: Linux x86 (32 bit) AS 188.8.131.52 package or Linux x86_64 (64 bit)AS 184.108.40.206 package. Unlike Windows, it is not necessary to download the 32 bit version. You may download the 64 bit version of Python, should you desire. However, your installation must be consistent. That means that every single package that you install must be the same version (if there is a choice).
Install as you do other Linux packages.
2. Testing Your Basic ActivePython Install
Now that you have installed ActivePython, it is a good idea to test the installation out, using the command shell for your OS. The command shell is a text-based version of the Windows Explorer or Finder; you can use it to move and rename files and folders. It is also how we will run Python in this class.
Using the command shell requires a bit of practice, so we have created a separate page of instructions for this. But for right now, all you need to learn from that page is how to start up the command shell for your OS.
Test 2(a): can your system find any sort of Python?
Open a command shell window. Then, type
(and hit return). This should put you in the "Python Interactive Shell"; you can tell this succeeded because a Python "banner" message will be printed out.
If instead you get some sort of error message suggesting that python could not be found, first reboot and try Test 2(a) again.
If you still get this kind of error message after rebooting, record the following information in order to report your problem.
Test 2(b): does the "banner" mention "ActivePython" and a version number of the form 2.7.x?The red highlight below shows what we're looking for.
If this test fails, your system is running the wrong python for this class.
First, try rebooting, and run Test 2(a) and Test 2(b) again.
If you still aren't getting ActivePython, record the following information in order to report your problem:
Test 2(c): can you interact with the Python Interactive Shell without it immediately crashing?
The > > > symbols are the prompt. To get the shell to do something, just type a Python command. For example, type
and hit Return (do not type the > > >; it is already there).
If anything other than the appearance of the numeral "2" happens, record the precise output, even if it's a very long error message (copy-and-paste is best) to report the problem to us.
Otherwise, you have a working installation of ActivePython.
3. Installing Komodo Edit
Next is to install is Komodo Edit. The purpose of Komodo Edit is to make it easy to create and edit modules/files that can be run by Python.
Technically, you can write Python modules in any text editor (word processor that only produces text, with no font or fancy formatting capabilities). NotePad and WordPad are text editors in Windows, while TextEdit is provided by OS X. The reason we use Komodo Edit is that it is the same across all platforms. That allows you to collaborate with partners who might be working on other operating systems.
To install Komodo Edit, first download the installer appropriate for your computer from Active State's KomodoIDE website, using the URL http://komodoide.com/download/#edit . Make sure you have the #edit in the URL: it is easy to confuse the (free) Komodo Edit, which is what we will use, with the (non-free) Komodo IDE; here's what to watch for.
Make sure you are seeing something like the right-hand illustration above, and click the appropriate button for Komodo Edit for your computer. You'll be brought to a page that asks for your email address; you don't have to enter it. After a few seconds, a file will download. Double-click on it (or, for a Mac DMG, follow the directions about control-clicking rather than double-clicking mentioned earlier) to begin the installation process.
3.1 Configuring Preferences: Make whitespace characters visibleOne of the most controversial aspects of Python is that it treats spaces and tabs very differently. If you accidentally put a tab in your program, it will cause your program will crash. And you will have a hard time finding it because both tabs and spaces look exactly the same.
To solve this problem, you need to change your preferences to help you distinguish between the two. Open Komodo Edit and then select the Preferences menu option (under Edit on Windows, under the Komodo menu-bar option on Macintosh). Choose the Editor category and check the box Show whitespace characters, as shown below.
This will allow you to see both tabs and spaces, and to tell the difference between both. Spaces will look like light dots which are centered vertically on each line. Tabs will look like black arrows. These are illustrated in the examples below.
3.2 Configuring Preferences: Make Komodo Edit see ActiveState python
If you needed to use the "Mac-Alias" steps above, then you also need to explicitly tell Komodo Edit that you want it to use ActivePython, as follows. If you didn't need to do the "Mac-Alias" steps, you're done with configuring Komodo Edit!
4. Adding necessary packages
We're going to set things up so you can access some plotting packages.
4.W: Get matplotlib and associated files on Windows
In a command shell, type
pypm install matplotlib
If you get a message saying something about pypm not being found, it means you didn't install ActivePython correctly. Please retry the instructions above and/or get in-person or Piazza help.
4.M: Get XQuartz and CornellExtensions on Mac
Unfortunately, Active State doesn't distribute matplotlib for macs. We've gone with a more "heavyweight" solution that installs more than you need for this course, but doesn't have complex installation instructions.
5. Test the necessary packages
For any OS, at the command line, type (or just copy-and-paste):
python -c "import numpy; print numpy.__version__; import matplotlib; print matplotlib.__version__"
You should get some version numbers out, like "1.1.1".
6. Appendix: Mac aliasing instructions
Follow these instructions if even after rebooting, Test 2(b) above still fails (that is, your computer is defaulting to some python other than ActivePython).
Unlike other semesters, where we've changed the order of places where your computer looks for programs by modifying your PATH variable, in this semester we're going to change what your system thinks the command "python" refers to, by creating an alias for the word "python". This means we are doing less to silently alter your system's setup in a way you might not understand, at the cost of a few more manual steps for you. Follow steps "Mac-Alias" below
|Course Material Authors: D. Gries, L. Lee, S. Marschner, C. Van Loan & W. White (over the years)|