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.
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.
If we are using Windows 10 we will see the following
SmartScreen warning where we will click to the
Run like below.
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 userswill install Python2 for all users currently exist in the operating system
Install just for mewill install Python2 for the current user and other operating system users can not use Python2.
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.
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.
Register Extensionswill set this installation as default Python by changing and setting registry values.
Tcl/Tkwill install features like Tkinter, IDLE, pydoc.
Documentationwill install Python HTMLHelp File.
Utility Scriptswill install some tools.
pipwill install the package manager for Python named Pip.
Test suitewill install
Lib/testlibraries and test suite.
Add python.exe to Pathis important because it will add the python interpreter to the operating system environment variables automatically. This will enable us to run
pythoncommand from the command line directly. By default these options is not selected we will select it manually.
As installing all of these things in Python2 we require Administrator rights which will be provided in the following screen by clicking
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.
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.
We will start the installation process of the Python3 by clicking the downloaded installer and the first screen provides us some options.
Install Nowwill install the Python3 directly without ant customization options.
Customize installationwill provide some options for the Python3 installation.
Add Python 3.7 to PATHwill 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.
Documentationwill install Python documentation files which can be helpful in internet isolated situations.
pipwill install Python package manager named Pip which can install, update, and remove 3rd party Python packages, modules, and libraries.
tcl/tk and IDLEwill install Tkinter libraries with the IDLE development environment.
Python test suitewill install a standard library test suite.
We will click to Next and will see the following
Advanced Options screen.
Install for all userswill install Python3 for all the users for the operating systems
Associate files with Pythonwill set the IDLE default editor for the Python or *.py extension files
Create shortcuts for installed applicationswill create shortcuts for Python interactive shell, IDLE, etc.
Add Python to environment variableswill add python interpreters and commands to the environment variables to execute them directly from the command line.
Precompiled standard librarywill also install the Python standard library as of Python source code, not DLL.
Download debugging symbolswill download debug symbols for the libraries which can be useful for debugging
Download debug binaries
Customize install locationwill 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.
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.
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
/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.
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 is the general name where it will redirect to the default Python version which can be Python2 or Python3.
> python --version > python > pip -V
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.
Python IDLE or Shell can run Python commands and script.