Install Python on Windows, Ubuntu and MacOs

Learn how to install Python on different operating systems, such as Windows, Ubuntu and MacOs, following the steps for each one.

» More Python Examples

Python 3 on Windows

Normally and unlike other operating systems, Windows does not come with Python pre-installed. However, to install Python on Windows, you just need to download the installer from the official site and run the installation wizard.

We recommend using the most recent version of Python 3, which will be something like 3.x.x (when this article was written it was possible to download version 3.7.3), For Windows you will have two download options, you can choose the 32-bit installer or the 64-bit one. To know which installer you should download, you should consider the following:

  • If your system has a 32-bit processor, choose the 32-bit installer.
  • On a 64-bit system, either installer will work fine. The 32-bit version will generally use less memory, but the 64-bit version works better for applications where performance is important.
  • If you are not sure which version to use and you can install the 64-bit version, then install this version.

Run the downloaded installer and make sure to select the option to add python to the Windows PATH.

Install Python Windows Ubuntu MacOs

You can now run Python from the command line.

python –version

Python 3 on Linux Ubuntu

Installing Python on Ubuntu depends on the version you use.

  • Ubuntu 17.10, Ubuntu 18.04 (and higher) come with Python 3.6 by default. You should be able to invoke it with the python3 command.
  • Ubuntu 16.10 and 17.04 do not come with Python 3.6 by default, but it is found in the universe repository. You should be able to install it with the following commands:
    • $ sudo apt-get update
    • $ sudo apt-get install python3.6

You can invoke python 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). 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 python3.6

You can invoke python with the command python3.6

Python 3 on Mac OS

While current versions of macOS (formerly known as “Mac OS X”) include a version of Python 2, it’s likely a few months out of date. The best way we have to install Python 3 on macOS is through the Homebrew package manager. This approach is also recommended by community guides The Hitchhiker’s Guide to Python.

Step 1: Install Homebrew (Part 1)

To get started, you will first need to install Homebrew:

  1. Go to the Homebrew page and look for the command under the heading “Install Homebrew”.
  2. Copy the command and make sure you have captured the full command text otherwise the installation will fail.
  3. Copy the command in a terminal and press Enter. This will start the Homebrew installation.
  4. If you’re doing this on a fresh installation of macOS, you might get a pop-up alert asking you to install Apple’s “command line developer tools”. You will need them to continue with the installation, so confirm the dialog by clicking “Install”.

At this point, you are probably waiting for the command line developer tools to finish installing and this will take a few minutes.

Step 2: Install Homebrew (Part 2)

You can continue installing Homebrew and then Python after completing the installation of the “command line developer tools”:

  1. Confirm the “The software was installed” dialog in the Developer Tools installer.
  2. Back in the terminal, press Enter to continue with the Homebrew installation.
  3. Homebrew will ask you to enter the user password to finish the installation. Add the password and press Enter to continue.
  4. Depending on your Internet connection, Homebrew will take a few minutes to download the necessary files. Once the installation is complete, the command prompt will reappear in the terminal window.

Step 3: Install Python

Once Homebrew has finished installing, return to the terminal and run the following command:

brew install python3

Note: When you copy this command, make sure you don’t include the $ character at the beginning. That’s just an indicator that this is a console command.

This will download and install the latest version of Python. Once the brew command finishes, Python 3 will be installed on your system.

You can make sure that everything worked correctly by checking if Python can be accessed from the terminal:

  1. Open a terminal.
  2. Type pip3 and press Enter.
  3. You should be able to see the help text for the Python “Pip” package manager. If you get an error message running pip3, repeat the Python installation steps again to make sure you have a working Python installation.

Assuming everything went well and you’ve seen the output of Pip in the terminal, then you’ve just installed Python and it’s ready to use.

We hope this instructions of how to Install Python on Windows, Ubuntu and MacOs will be useful for you.