How To Install Python (Python2 and Python3) On Windows? – POFTUT

How To Install Python (Python2 and Python3) On Windows?

Python is a very popular and useful programming and scripting language. What makes Python so popular and useful is its rich modules, easy learning, and usage, and being cross-platform. In this tutorial, we will learn how to install Python2, Python3 interpreter, tools, and libraries.

Python2 vs Python3

Python3 is the latest version of the Python programming language. Python2 is the previous version which is used for a long time. Python3 provides more performance, features, and modernity according to the Python2. But some Python projects maybe depend on Python2.

Install Python 2

Python downloads for Windows are provided from the following link where both Python2 and Python3 can be found here. But we will download the Python2 from the following link.

Python2 and Python3 Download Page

When we click to the Latest Python2 Release we will be redirected to the Python 2 download page which can be also accessed from the following link. We will select the architecture of the Windows operating system like 32 or 64-bit. In this case, we will download the 64-bit installation MSI file.

Python2 32 and 64 Bit Installer Download
Python2 32 and 64 Bit Installer Download

If we are using Windows 10 we will see the following SmartScreen warning where we will click to the Run like below.

SmartScreen Warning For Python2
SmartScreen Warning For Python2

With the following screen, the Python2 installation will start. In the following screen, we have two options in order to select for which users we want to install Python2.

  • Install for all users will install Python2  for all users currently exist in the operating system
  • Install just for me will install Python2 for the current user and other operating system users can not use Python2.
Python 2 Install User
Python 2 Install User

In the following screen, we will specify the Python2 installation path. All files, libraries, interpreters, and tools will be stored in this path. By default C:\Python27 is used but we can change whatever we want.

Specify The Python2 Installation Path
Specify The Python2 Installation Path

In the following screen, we will customize the Python2 installation. We can select the features we want to install. By default, most of the features are selected for installation which is very beneficial. We will also select the  Add python.exe to Path options which is very important.

Select Features To Install Python2
Select Features To Install Python2
  • Register Extensions will set this installation as default Python by changing and setting registry values.
  • Tcl/Tk will install features like Tkinter, IDLE, pydoc.
  • Documentation will install Python HTMLHelp File.
  • Utility Scripts will install some tools.
  • pip will install the package manager for Python named Pip.
  • Test suite will install Lib/test libraries and test suite.
  • Add python.exe to Path is important because it will add the python interpreter to the operating system environment variables automatically. This will enable us to run python command from the command line directly. By default these options is not selected we will select it manually.
LEARN MORE  Introduction To Memcached with Telnet and Python

As installing all of these things in Python2 we require Administrator rights which will be provided in the following screen by clicking Yes.

Provide Admin Rights For Python2 Installation
Provide Admin Rights For Python2 Installation

Following screen is about the file copy, registry change phase.

If the Python2 is installed without a problem we will see the following screen which says installation is completed successfully.

Python2 Installation Successful
Python2 Installation Successful

Install Python 3

Python3 is the latest main version of the Python programming language. The minor version for Python3 is 7 which means the latest version for Python is Python3.7. We can download the Python3 installer for the Windows operating system from the following page. There are 32 and 64-bit installers for the Python3. Also web-based installer can be used to download installation files from the internet but this will require internet access.

Python3 Installers List For Windows
Python3 Installers List For Windows

We will start the installation process of the Python3 by clicking the downloaded installer and the first screen provides us some options.

Select Python3 Installatin Type
  • Install Now will install the Python3 directly without ant customization options.
  • Customize installation will provide some options for the Python3 installation.
  • Add Python 3.7 to PATH will add Python3 interpreter and command to the Windows PATH where the python command can be run directly.

We will select the Customize Installation where we want to see and set some options.

Select Python3 Installation Optional Features
  • Documentation will install Python documentation files which can be helpful in internet isolated situations.
  • pip will install Python package manager named Pip which can install, update, and remove 3rd party Python packages, modules, and libraries.
  • tcl/tk and IDLE will install Tkinter libraries with the IDLE development environment.
  • Python test suite will install a standard library test suite.
LEARN MORE  Memcached Increment and Decrement Operations with Python Example

We will click to Next and will see the following Advanced Options screen.

Select Python3 Installation Advanced Options
  • Install for all users will install Python3 for all the users for the operating systems
  • Associate files with Python will set the IDLE default editor for the Python or *.py extension files
  • Create shortcuts for installed applications will create shortcuts for Python interactive shell, IDLE, etc.
  • Add Python to environment variables will add python interpreters and commands to the environment variables to execute them directly from the command line.
  • Precompiled standard library will also install the Python standard library as of Python source code, not DLL.
  • Download debugging symbols will download debug symbols for the libraries which can be useful for debugging
  • Download debug binaries
  • Customize install location will specify the installation path for the Python3 which is the current user home directory.

Then we will click to the Install to start the installation process. During the installation, we will see a similar screen to the following where the bar will show the installation percentage.

Python3 Setup Progress

After the installation is successful we will see the following Setup was successful screen. We can click the Close button but we can also click to Diable path length limit which will bypass the MAX_PATH limitation.

Python3 Installed Succesfully

Non-interactive Python Installation

In the previous part, we have installed Python2 and Python3 interactively by using a GUI and clicking the Next buttons. We have also provided some configuration via checkboxes by enabling and disabling them. The Non-interactive Python Installation will install Python2 via MS-DOS command line with no user interaction. We will just provide some parameters to the non-interactive installation for install configuration. For normal installation, we will just use msiexe command /i option for installation and provide the Python MSI installation file path and name.

> msiexec /i python-2.5.msi

For more detailed configuration some options and values can be provided to change default options like installation path, user, GUI.

  • /qn – No interface
  • /qb – Basic interface – just a small progress dialog
  • /qb! – Like /qb, but hide the Cancel button
  • /qr – Reduced interface – display all dialogs that don’t require user interaction (skip all modal dialogs)
  • /qn+ – Like /qn, but display “Completed” dialog at the end
  • /qb+ – Like /qb, but display “Completed” dialog at the end
  • TARGETDIR=D:\python2 for installation target directory
  • ALLUSERS=1 will install for all users but this requires Administrator privileges for the current MS-DOS or command-line interface.
LEARN MORE  Memcached Check and Set Operation with Python Example

Web-Based/Online Python Installation

Normally Python installation executables contain all require data, executable, libraries and binary. There is no need to get extra data from remote. But Web-based Python Installation only provides the installation executable and all other Python tools are downloaded from the internet or web. All other configurations are the same as the regular Python installation.

Install and Update Python2 or Python3 With Chocolatey Package Manager

Chocolatey is a package manager for Windows operating systems similar to the apt and dnf for Linux distributions. Python can be installed via Chocolatey with a single command. Following command will install the latest Python3 release to the current Windows operating system.

> choco install python

Also already install Python can be updated/upgraded to the latest version with the following command.

> choco upgrade python

If we do not need the Python we can use the chocolatey package manager in order to remove/uninstall currently installed Python.

> choco uninstall python

Check and Verify Python Version

We can check the installed Python version in different ways. python or Python is the general name where it will redirect to the default Python version which can be Python2 or Python3.

> python --version

> python

> pip -V
Check and Verify Python Version
Check and Verify Python Version

We can check the Python2 or Python3 version in detail by just running their specific commands like below.

> python2 --version


> python3 --version

Open Installed Python Shell and Run Python Script

Python provides the IDLE for creating and running Python scripts. IDLE also works as a interactive shell or command line for Python language. We can open the IDLE from the Programs of start menu under the Python item like below. Alternatively we can type the Python IDLE to the start menu where Python IDLE will be listed.

Open Python IDLE

Python IDLE or Shell can run Python commands and script.

Run Python Command On IDLE

Leave a Comment