[[installation]]
== Installation

When we refer to "Python 2" in this book, we will be referring to any version of Python equal to or
greater than version https://www.python.org/downloads/[*2.7*].

[[install_windows]]
=== Installation on Windows

Visit https://www.python.org/downloads/ and download the latest version. The installation is just
like any other Windows-based software.

CAUTION: When you are given the option of unchecking any "optional" components, don't uncheck any.

[[dos_prompt]]
==== DOS Prompt

If you want to be able to use Python from the Windows command line i.e. the DOS prompt, then you
need to set the PATH variable appropriately.

For Windows 2000, XP, 2003 , click on +Control Panel+ -> +System+ -> +Advanced+ -> +Environment
Variables+. Click on the variable named +PATH+ in the _System Variables_ section, then select
+Edit+ and add `;C:\Python27` (please verify that this folder exists, it will be different for
newer versions of Python) to the end of what is already there. Of course, use the appropriate
directory name.

For older versions of Windows, open the file `C:\AUTOEXEC.BAT` and add the line
`PATH=%PATH%;C:\Python33` and restart the system. For Windows NT, use the +AUTOEXEC.NT+ file.

For Windows Vista:

. Click Start and choose +Control Panel+
. Click System, on the right you'll see "View basic information about your computer"
. On the left is a list of tasks, the last of which is +Advanced system settings+. Click that.
. The +Advanced+ tab of the +System Properties+ dialog box is shown. Click the +Environment
Variables+ button on the bottom right.
. In the lower box titled +System Variables+ scroll down to Path and click the +Edit+ button.
. Change your path as need be.
. Restart your system. Vista didn't pick up the system path environment variable change until I
restarted.

For Windows 7 and 8:

. Right click on Computer from your desktop and select +Properties+ or click +Start+ and choose
+Control Panel+ -> +System and Security+ -> +System+. Click on +Advanced system settings+ on the
left and then click on the +Advanced+ tab. At the bottom click on +Environment Variables+ and under
+System variables+, look for the +PATH+ variable, select and then press +Edit+.
. Go to the end of the line under Variable value and append `;C:\Python27` (please verify that this
folder exists, it will be different for newer versions of Python) to the end of what is already
there. Of course, use the appropriate folder name.
. If the value was `%SystemRoot%\system32;` It will now become `%SystemRoot%\system32;C:\Python27`
. Click +OK+ and you are done. No restart is required, however you may have to close and reopen the
command line.

==== Running Python prompt on Windows

For Windows users, you can run the interpreter in the command line if you have <<dos_prompt,set the
`PATH` variable appropriately>>.

To open the terminal in Windows, click the start button and click +Run+. In the dialog box, type
+cmd+ and press kbd:[enter] key.

Then, type +python+ and ensure there are no errors.

[[install_osx]]
=== Installation on Mac OS X

For Mac OS X users, Python must be installed already.

To verify, open the terminal by pressing kbd:[Command + Space] keys (to open Spotlight search),
type +Terminal+ and press kbd:[enter] key. Now, run +python+ and ensure there are no errors.

[[install_linux]]
=== Installation on GNU/Linux

For GNU/Linux users, Python must be installed already.

To verify, open the terminal by opening the +Terminal+ application or by pressing kbd:[Alt + F2]
and entering +gnome-terminal+. If that doesn't work, please refer the documentation of your
particular GNU/Linux distribution. Now, run +python+ and ensure there are no errors.

You can see the version of Python on the screen by running:

--------------------------------------------------
$ python -V
Python 2.7.6
--------------------------------------------------

NOTE: `$` is the prompt of the shell. It will be different for you depending on the settings of the
operating system on your computer, hence I will indicate the prompt by just the `$` symbol.

CAUTION: Output may be different on your computer, depending on the version of Python software
installed on your computer.

=== Summary

From now on, we will assume that you have Python installed on your system.

Next, we will write our first Python program.
