Software Installation and Lab Setup
To work on the projects in Explorations in Computing you need to have Python running on your computer and you need to install the lab modules, which are all written in Python.
A terminal emulator is a program that allows users to run software using a "command line interface." Every operating system comes with a terminal emulator application, and we recommend you take some time to find your terminal emulator and learn how it works.
Although you can run Python programs without a terminal emulator, you will have to use it for one of the installation steps, and many programmers prefer the terminal emulator as the most convenient way to run their programs.
The terminal emulator on Microsoft Windows is an application called Comamnd Prompt. From the Start menu, click on "All Programs", then "Accessories", and then "Command Prompt".
When you first launch the program you should see a window that looks like this:
The greater-than symbol next to your user name is called a prompt. When you see this symbol, with the text cursor next to it, the system is ready for you to enter a command.
There are several dozen commands, but you only need to be familiar with a few of them for the projects in this book. Two you need right away, to install the lab software, are dir and cd. Take some time now to become familiar with these commands and to learn how to find files on your system using Command Prompt. Here are some useful tutorials for beginners:
The terminal emulator in Linux is called (naturally enough) Terminal. You can find it in the Applications folder, and you might already have a desktop icon for it.
When you first launch the program you should see a window that looks like this:
The dollar sign is called a prompt. When you see this symbol, with the text cursor next to it, the system is ready for you to enter a command.
There are several dozen commands, but you only need to be familiar with a few of them for the projects in this book. Two you need right away, to install the lab software, are dir and cd. Take some time now to become familiar with these commands and to learn how to find files on your system using the terminal. Here are some useful tutorials for beginners:
The terminal emulator in Mac OS X is an application named Terminal. To find it, open your Applications folder and look inside it for another folder called Utilities. Terminal and many other useful systems management applications are in Utilities.
When you first launch the program you should see a window that looks like this:
The dollar sign is called a prompt. When you see this symbol, with the text cursor next to it, the system is ready for you to enter a command.
There are several dozen commands, but you only need to be familiar with a few of them for the projects in this book. Two you need right away, to install the lab software, are dir and cd. Take some time now to become familiar with these commands and to learn how to find files on your system using the terminal. These links were written for Linux users, but the commands are the same on Mac OS X:
Python is a programming language that is widely used by web page developers and other software professionals. It is open source software, and can be freely downloaded and installed on any computer.
If you already have Python 3.2 or later on your system you can skip to the next section (Install PythonLabs).
Otherwise go to http://python.org. Click on the box named "Download". When you see "Download the latest versions of Python" select the latest version of Python 3 (as of January, 2015 this was Python 3.4.2).
When this new page loads, go to the bottom of the page, where you will see a list of installer files.
You probably want the file named "Windows x86-64 MSI installer" (unless your operating system is configured to run only 32-bit applications).
You can either save the installer to your hard drive, or tell Internet Explorer to run the program.
The simplest choice is to tell Explorer to go ahead and run the installer.
If you're nervous about automatically installing software downloaded from the Internet, tell Explorer to save the file, and then use a virus checking program to verify the MD5 checksum. If you're not familiar with these checksums, you can learn more about how they work and download a File Checksum Integrity Verifier from Microsoft Support.
As the installer runs it will show you a series of options.
Accept the default options until you get to a place where the screen says "Customize Python 3.4.2."
At this point scroll down to the bottom of the window and select "Add python.exe to Path."
After you click the button next to the "Add python..." option the installer window should look something like this:
Make sure both of the options circled in red above are selected. Tcl/Tk (probably already selected as the default) is required by labs that draw animations on the screen.
To install Python on Ubuntu or similar systems, make sure your system is connected to the Internet, and then start the Terminal application and type this command:
sudo apt-get install python3 python3-tk tk
You will be asked to type your password (when you type your password on a Linux command line it looks like nothing is happening, but just continue typing your password and hit the return key). After you hit the return key the system will begin the installation.
If you're wondering what all these words mean, sudo tells Linux you are the system administrator (the "su" is short for "superuser") and you have the authority to do this installation. The word apt-get is the name of the program that does the installation. The remaining words (python3, tk, etc.) are the names of the programs you want to install. They are all pieces that are required to make a complete Python installation.
To make sure you have the latest version of Python on your system, download an installer from http://python.org. In the section called Downloads, find the link to the latest version of Python 3 (as of January, 2015 this was Python 3.4.2).
When this new page loads, go to the bottom of the page, where you will see a list of installer files.
Click on the link called "Mac OS X 64-bit/32-bit installer".
After the installer has been copied to your system find the package in your Downloads folder, double-click on the package icon, and follow the instructions, using all the default options.
In order to work on projects that use interactive graphics you will also need a software package named Tcl/Tk. This package contains a library that is widely used for creating windows, buttons, and other parts of graphical user interfaces. The version we use comes from an organization called ActiveState.
Download the installer from ActiveTcl Downloads. On the Downloads page you will see a table with different operating systems and different versions of Tcl. Find the Mac Disk Image for Tcl Version 8.5.15.0.
Important: Make sure you download Version 8.5 and not the more recent Version 8.6.
After the package has downloaded you should see a file named ActiveTcl-8.5.pkg in your Downloads folder. Double-click on this package to start the installation process. When prompted, choose the default settings whenever you are asked to select an option.
The PythonLabs software is a set of Python modules written specifically for the projects in this book.
Here are the specific instructions for each operating system.
If you have Microsoft Windows 7 click on the following link to download the lab module installer:
PythonLabs-1.0.2.win-amd64.exe
Let Internet Explorer run the installer. There are no options to specify, so when the installer exits the software should be in place.
If the installer fails, or if you have a different version of Microsoft Windows, download the following file and save it in your Downloads folder:
PythonLabs-1.0.2.zip
Start your File Browser, go to the Downloads folder, and double-click on the icon for the zip file you just downloaded.
You should now see a new folder with the same name, but without the .zip extension.
Drag this folder to your Desktop. Your desktop and Downloads window should now look something like this:
Next start Command Prompt and type the following commands to install the lab modules:
cd Desktop\PythonLabs-1.0.2
python setup.py install
Download the lab modules by clicking on this link:
PythonLabs-1.0.2.tar.gz
If your browser asks you what you want to do with the file tell it you want to save it in your Downloads folder.
Start Terminal and type this cd command to navigate to your Downloads folder:
cd Downloads
Type the following commands to unpack and install the modules:
gunzip PythonLabs-1.0.2.tar.gz
tar xf PythonLabs-1.0.2.tar
cd PythonLabs-1.0.2
sudo python3 setup.py install
You will see a lot of messages flash by on the screen, but you can ignore them.
Start Command Prompt (see the instructions in the section on "Terminal Emulators" above) and type the following command to start an interactive session with Python:
python
When you see Python's prompt (three greater-than symbols) type this command to load one of the PythonLabs modules:
from PythonLabs.Tools import *
Next type this command to test the installation:
hello()
If everything is working you will see a message that says "PythonLabs is installed" and a new window will pop up with the word "Hello" in it.
In your Terminal window type the following command to start an interactive session with Python:
python3
When you see Python's prompt (three greater-than symbols) type this command to load one of the PythonLabs modules:
from PythonLabs.Tools import *
Next type this command to test the installation:
hello()
If PythonLabs is working you will see a message that says "PythonLabs is installed." If Tcl/Tk is installed and working you will also see a window pop up with the word "Hello" in it.