Python (2016)

CHAPTER 4: Installing Python

In the first chapter, we went into detail about the different implementations of the Python programming language. Before one can successfully code, one has to make sure he has the necessary tools—that means getting Python into your device. If you are lucky (read: if you have the right operating system), you might not even need to download it as it might have come pre-installed. If you wish to check if you already have Python, simply open up your system’s Command Line Interface (CLI) and type “python” (minus the quotes). If you see a response—typically comprised of the word “Python” and some build information with the version number—then you are good to go. For example, here is an example of the response that would show up when using a 32-bit Windows XP:

Python 2.7.2 (v3.4.2:ab3c023a9432, Jan9 2016, 10:11:04 [MSC v.1600 32 bit (Intel)] on win32

Type “help”, “copyright”,”credits” or “license” for more information.

>>> 

Or if you are using Win 7 64-bit, then you will see the following response:

Python 2.7.2 (v3.4.2:ab3c023a9432, Jan9 2016, 10:11:04 [MSC v.1600 64 bit (AMD64)] on win32

Type “help”, “copyright”,”credits” or “license” for more information.

>>> 

In case you get an error as a response, then you will need to download Python first.

Downloading Python

Fortunately, downloading Python is a breeze. It is recommended that you get the latest version, if possible in the 3.X series (since it is the one that gets the most active developments). If you prefer, you can still get the 2.X branch. Be reminded, however, that no future development of this branch is planned (with the most recent release being way back in 2010). The major implementation (CPython) is available on www.python.org/downloads/

Windows and Mac OSX users can easily download an installer which will do all the work that is needed to get Python to your system. If you instead use Linux (or another Unix-like operating system), then you can build the binaries from the source code itself. There are some distros in the Linux world that allow Python to be installed more easily, coming in the form of pre-made binaries. For many of the most popular Linux distros, documentation should be available on the website.

Also, do not skip ahead to this step without trying out the previous one—checking your device for any pre-installed versions of Python. Note that most Linux and Mac machines already come with a form of Python installed—almost always the 2.X branch. Remember that this is not compatible with 3.X, so if you wish to upgrade you can still download.

Python Online

In case you are working from a different device, or if you decide that downloads may pose a security risk, or in case you just want to work online for any reason -- you’re in luck. An interactive shell for the language is offered by the Python Software Foundation. This comes by the name PythonAnywhere, and is available on their website. This has more implementations than vanilla CPython, and as a plus no download or reinstallation is required. On the other hand, you will not be able to execute scripts and files from this shell, hindering the more advanced Python learners.