Here we will look forward to the installation of Python on three different OS platforms, namely, Windows, Linux, and Mac OS. Let's begin with the Windows platform.
Installation
Installation on Windows platform
Python 2.x can be downloaded from https://www.python.org/downloads. The installer is simple and easy to install. Perform the following steps to install the setup:
- Once you click on setup installer, you will get a small window on your desktop screen as shown here; click on Next:
- Provide a suitable installation folder to install Python. If you don't provide the installation folder, then the installer will automatically create an installation folder for you, as shown in the following screenshot. Click on Next:
- After completion of step 2, you will get a window to customize Python as shown in the preceding screenshot. Notice that the Add python.exe to Path option has been marked x. Select this option to add it to system path variable (which will be explained later in the chapter), and click on Next:
- Finally, click on Finish to complete the installation:
Installation on Linux platform
These days most of the Linux-based systems come preloaded with Python, so in most cases, you do not need to install it separately. However, if you do not find your desired version of Python on the Linux platform, you can download your desired version for a particular Linux platform from the site https://www.python.org/downloads/source/. Perform the following steps:
- Extract the compressed file using the tar -xvzf python_versionx.x command.
- Browse the directory of the compressed file as shown in the screenshot:
- Run the following commands:
[root@localhost Python-2.7.12]# ./configure
[root@localhost Python-2.7.12]# make
[root@localhost Python-2.7.12]# make install
- Use the command as shown in screenshot to ensure that Python is running:
Installation on Mac OS
For Mac OS, you will get the installer from the site https://www.python.org/downloads/mac-osx/.Â
For the new Mac OS X, Sierra comes loaded with Python 2.7 and it's good for learning but the same cannot be used to develop advanced-level programs. You do not need to separately install Python on the new Mac OS X. However, a word of caution is that the version of Python packed with the Mac OS could be out of date and might require updating. If you still want to install a separate version, you can follow the simple steps mentioned as follows:
- First of all, you might require to install Xcode, Xcode is the IDE for  platform and can be downloaded from the Apple appstore.
- Once Xcode is installed, you need to install the command-line tools, which can be installed by running the xcode-select --install command on the terminal found under /Applications/Utilities/, as shown in the following screenshot:
- Â A pop-up window appears with three different options as shown here:
- Once you click on Install and agree to their terms and conditions, the command-line tools will start to download and will be installed in few minutes depending on the Internet connection.
-
The next step in the process would be to install Homebrew, which is a package manager for Mac OS and handles the Python package. In order to install Homebrew, simply provide the following inputs to the terminal:
/usr/bin/ruby -e "$(curl -fsSL
https://raw.githubusercontent.com/Homebrew/install/master/install)"
- To install the latest python2 version, simply type brew install python on the terminal:
$ brew install python