Test Author | Nov 07, 2020
Windows
It is highly unlikely that your Windows system shipped with Python already installed. Windows systems typically do not. Fortunately, installing does not involve much more than downloading the Python installer from the python.org website and running it. Let’s take a look at how to install Python 3 on Windows:
Step 1: Download the Python 3 Installer
1. Open a browser window and navigate to the Download page for Windows at python.org. 2. Underneath the heading at the top that says Python Releases for Windows, click on the link for the Latest Python 3 Release - Python 3.x.x. (As of this writing, the latest is Python 3.6.5.)
3. Scroll to the bottom and select either Windows x86-64 executable installer for 64-bit or Windows x86 executable installer for 32-bit. (See below.)
Step 2: Run the Installer
Once you have chosen and downloaded an installer, simply run it by double-clicking on the downloaded file. A dialog should appear that looks something like this:
Important: You want to be sure to check the box that says Add Python 3.x to PATH as shown to ensure that the interpreter will be placed in your execution path.
Then just click Install Now. That should be all there is to it. A few minutes later you should have a working Python 3 installation on your system.
Linux
There is a very good chance your Linux distribution has Python installed already, but it probably won’t be the latest version, and it may be Python 2 instead of Python 3.
To find out what version(s) you have, open a terminal window and try the following commands:
∙ python --version
∙ python2 --version
∙ python3 --version
One or more of these commands should respond with a version, as below:
$ python3 --version
Python 3.6.5
If the version shown is Python 2.x.x or a version of Python 3 that is not the latest (3.6.5 as of this writing), then you will want to install the latest version. The procedure for doing this will depend on the Linux distribution you are running..
Ubuntu
Depending on the version of the Ubuntu distribution you run, the Python install instructions vary. You can determine your local Ubuntu version by running the following command:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.4 LTS
Release: 16.04
Codename: xenial
Depending on the version number you see under Release in the console output, follow the instructions below:
∙ Ubuntu 17.10, Ubuntu 18.04 (and above) come with Python 3.6 by default. You should be able to invoke it with the command python3.
∙ Ubuntu 16.10 and 17.04 do not come with Python 3.6 by default, but it is in the Universe repository. You should be able to install it with the following commands:
∙ $ sudo apt-get update
∙ $ sudo apt-get install python
or
∙ $ sudo apt-get install python3.6
You can then invoke it with the command python3.6.
∙ If you are using Ubuntu 14.04 or 16.04, Python 3.6 is not in the Universe repository, and you need to get it from a Personal Package Archive (PPA). For example, to install Python from the “deadsnakes” PPA, do the following:
∙ $ sudo add-apt-repository ppa:deadsnakes/ppa
∙ $ sudo apt-get update
∙ $ sudo apt-get install python
or
∙ $ sudo apt-get install python3.6
As above, invoke with the command python3.6.
Linux Mint
Mint and Ubuntu use the same package management system, which frequently makes life easier. You can follow the instructions above for Ubuntu 14.04. The “deadsnakes” PPA works with Mint.
Debian
We found sources that indicated that the Ubuntu 16.10 method would work for Debian, but we never found a path to get it to work on Debian 9. Instead, we ended up making Python from source as listed below.
One issue with Debian, however, is that it generally does not install the sudo command by default. To install it, you’ll need to do the following before you carry out the Compiling Python From Source instructions below:
$ su
$ apt-get install sudo
$ vi /etc/sudoers
After that, open the /etc/sudoers file using the sudo vim command (or your favorite text editor.) Add the following line of text to the end of the file, replacing your_username with your actual username:
your_username ALL=(ALL) ALL
openSUSE
We found several sites describing how to get zypper to install the latest version of Python, but they seemed problematic or outdated. We did not manage to get any of them to work successfully, so we fell back to building Python from source. To do that, you will need to install the development tools, which can be done in YaST (via the menus) or by using zypper:
$ sudu zypper install -t pattern devel_C_C++
This step took a while and involved the installation of 154 packages, but once it was completed, we were able to build the source as shown in the Compiling Python From Source section above.
CentOS
The IUS Community does a nice job of providing newer versions of software for “Enterprise Linux” distros (i.e. Red Hat Enterprise and CentOS). You can use their work to help you install Python 3.
To install, you should first update your system with the yum package manager:
$ sudo yum update
$ sudo yum install yum-utils
You can then install the CentOS IUS package which will get you up to date with their site:
$ sudo yum install https://centos7.iuscommunity.org/ius-release.rpm
Finally you can then install Python and Pip:
$ sudo yum install python36u
$ sudo yum install python36u-pip
Thanks to Jani Karhunen for his excellent writeup for CentOS 7.