Log in / Register
Home arrow Computer Science arrow Python Programming Fundamentals
< Prev   CONTENTS   Next >

1.2 Installing Python and Wing IDE 101

To begin writing Python programs on your own computer, you need to have Python installed. There were some significant changes between Python 2.7 and Python 3 which included a few changes that make programs written for version 3 incompatible with programs written for version 2.7 and vice versa. If you are using this book as part of an introductory course, your instructor may prefer you install one version or the other. Example programs in this text are written using Python 3 syntax but the differences between Python 2 and 3 are few enough that it is possible to use either Python 2 or 3 when writing programs for the exercises in this text. Inset boxes titled

Python 2 "/' 3 will highlight the differences when they are first encountered in the text.

If you are running Windows you will likely have to install Python yourself. You can get the installation package from Click the DOWNLOAD link on the page. Then pick the appropriate installer package. Most will want to download the latest version of the Python 3 Windows x86 MSI Installer package. Once you have downloaded it, double-click the package and take all the defaults to install it as pictured in Fig. 1.2.

If you have a Mac, then Python is already installed and may be the version you want to use, depending on how new your Mac is. You can find out which version of Python you have by opening a terminal window. Go to the Applications folder and look in the Utilities sub-folder for the Terminal application. Start a terminal and in the window type python. You should see something like this:

Kent 's Mac > python

Python 3.1.1 ( r311 : 74543 , Aug 24 2009 , 18:44:04)

[ GCC 4.0.1 ( Apple Inc . build 5493)] on darwin

Type " help ", " copyright ", " credits " or " license " for more info .


You can press and hold the control key (i.e. the ctrl key) and press 'd' to exit Python or just close the terminal window. If you do not have version 3.1 or newer installed on your Mac you may wish to download the latest Python 3 MacOS Installer Disk Image from the web site. Once the file is downloaded you can doubleclick the disk image file and then look for the Python.mpkg file and double-click it as pictured in Fig. 1.3. You will need an administrator password to install it which in most cases is just your own password.

While you don't need an IDE like Wing to write and run Python programs, the debugger support that an IDE like Wing provides will help you understand how Python programs work. It is also convenient to write your programs in an IDE so you can run them quickly and easily. To install Wing IDE 101 you need to go to the

Fig. 1.3 Installing Python on Mac OS X

Fig. 1.4 Installing Wing IDE 101 on Windows web site. Find the Download link at the top of the web page and select Wing IDE 101 to download the installation package. Be sure to pick Wing IDE 101 to download if you don't want to pay for a license. If you are installing on a Mac, pick the Mac version. If you are installing on Windows, pick the Windows version. Download and run the installation package if you are using Windows. Running the Windows installer should display an installer window like that pictured in Fig. 1.4. Take all the defaults to install it.

If you are installing Wing IDE 101 on a Mac then you need to mount the disk image. To do this you must double-click a file that looks like wingide-101-3.2.2-1i386.dmg. After double-clicking that file you will have a mounted disk image of the same name, minus the .dmg extension). If you open a Finder window for that disk image you will see a window that looks like Fig. 1.5. Drag the Wing IDE icon to your Applications folder and you can add it to your dock if you like.

1.2.1 Configuring Wing

If you look at Fig. 1.8 you will see that the Python interpreter shows up as Python

3.1.1. When you install Wing, you should open it and take a look at your Python Shell tab. If you see the wrong version of Python then you need to configure Wing to use the correct Python Shell. To do this you must open Wing and go to the Edit menu. Under

Fig. 1.5 Installing Wing IDE 101 on a Mac

the Edit menu, select Configure Python... and type in the appropriate interpreter. If you are using a Mac and wish to use version 3.1 then you would type python3.1. Figure 1.6 shows you what this dialog box looks like and what you would type in on a Mac. In Windows, you should click the browse button and find python.exe. This

will be in a directory like C:Python31 if you chose the defaults when installing.

Fig. 1.6 Configuring Wing's Python Interpreter

Fig. 1.7 Configuring Indent Guides

There is one more configuration change that should be made. The logical flow of a Python program depends on the program's indentation. Since indentation is so important, Wing can provide a visual cue to the indentation in your program called an indent guide. These indent guides will not show up in this chapter, but they will in subsequent chapters. Go to the Edit menu again and select Preferences. Then click on the Indentation selection in the dialog box as shown in Fig. 1.7. Select the checkbox that says Show Indent Guides.

That's it! Whether you are a Mac or Windows user if you've followed the directions in this section you should have Python and Wing IDE 101 installed and ready to use. The next section shows you how to write your first program so you can test your installation of Wing IDE 101 and Python.

Found a mistake? Please highlight the word and press Shift + Enter  
< Prev   CONTENTS   Next >
Business & Finance
Computer Science
Language & Literature
Political science