Python Environment Setup

Python is available for use with Windows, Linux, Mac OS as well as certain other platforms such as IBM AS/400, iOS, Solaris, etc.

To install Python on your local machine, get a copy of the standard distribution of Python software from https://www.python.org/downloads based on your operating system, hardware architecture and version of your local machine.

Install Python on Windows:

To install Python on a Windows platform, you need to download the installer. A web-based installer, executable installer and embeddable zip files are available to install Python on Windows. Visit https://www.python.org/downloads/windows and download the installer based on your local machine's hardware architecture.

The web-based installer needs an active internet connection. So, you can also download the standalone executable installer. Visit https://www.python.org/downloads and click on the Download Python 3.7.0 button as shown below. (3.7.0 is the latest version as of this writing.)

Download Python Library

This will download python-3.7.0.exe for 32 bit. For the 64 bit installer, go to https://www.python.org/downloads/windows and select the appropriate 64 bit installer, as shown below.

Download Python for Windows 64 bit

Download the Windows x86-64 executable installer and double click on it to start the python installation wizard as shown below.

Python Installation Wizard

Installation is a simple wizard-based process. As you can see in the above figure, the default installation folder will be C:\Users\{UserName}\AppData\Local\Programs\Python\Python37 for Python 3.7.0 64 bit. Check the Add Python 3.7 to PATH checkbox, so that you can execute python scripts from any path. You may choose the installation folder or feature by clicking on Customize installation. This will go to the next step of optional features, as shown below.

Python Installation Wizard

Click Next to continue.

Python Installation Wizard

In Advanced Options, select the Install for all users option so that any user of your local machine can execute Python scripts. Also, choose the installation folder to make a shorter path for Python executable (something like C:\python37), keeping the rest of the choices to default and finally click on the Install button.

Python Installation Wizard

After successful installation, you can start working with Python on your local machine.

Install Python on Linux

Most of Linux distributions come with Python already installed. However, the Python 2.x version is incorporated in many of them. To check if Python 3.x is available, run the following command in the Linux terminal:

$ which python3

If available, it will return the path to the Python3 executable as /usr/local/bin/python3. If not, install it by following the procedure on Ubuntu Linux:

$ sudo apt-get update
$ sudo apt-get install python3.6

For other Linux distributions use the corresponding package managers, such as YUM for Red Hat, aptitude for debian, DNF for Fedora, etc.

For installation on other platforms as well as installation from the source code, please refer to the official documentation on python.org

To check whether Python installation is successful, open the command prompt window, type Python and press ENTER. A Python Prompt comprising of three Greater Than symbols (>>>) should appear.

Python Shell on Windows

Learn about Python shell in the next chapter.