Skip main navigation
We use cookies to give you a better experience, if that’s ok you can close this message and carry on browsing. For more info read our cookies policy.
We use cookies to give you a better experience. Carry on browsing if you're happy with this, or read our cookies policy for more information.

Skip to 0 minutes and 1 secondBefore you start learning anything about Python, you need to have it installled on your computer. Now confusingly, there were two different versions of the Python programming language-- there's Python 2 and there's Python 3. So which should you learn? A quick search online will reveal that there was some controversy over which version of the language is best to learn when getting started. In the early days of Python 3, there was very little support for the language. Most code available on the web was all written in Python 2. This resulted in a lot of people recommending new learners learn Python 2 rather than Python 3. This is no longer the case, however.

Skip to 0 minutes and 41 secondsPython 3 is now very well supported and Python 2 will no longer be officially supported in a little over two years. If you're going to learn to programme in Python, then you want be using Python 3. So now let's spend a little bit of time seeing how we can install Python 3 on each of the three major operating systems. Feel free to skip ahead to the operating system that is relevant to you. On Microsoft Windows, your first step is to open up your web browser.

Skip to 1 minute and 17 secondsYou can then navigate to www.python.org/download. On the web page that opens up, you'll see a button to install the latest version of Python 3. Clicking the button will download an executable file. You can click on this to run it.

Skip to 1 minute and 47 secondsIn the dialog box that opens up, it's important to check the box to add Python 3 to your PATH. Then, you can go ahead and click install Now. The setup process will take a little bit of time.

Skip to 2 minutes and 10 secondsOnce set up is complete, click on Done. And then, you can close your web browser. Clicking in the Start menu, you should be able to find IDLE, which is a fairly good interactive development environment for new beginners to use with Python.

Skip to 2 minutes and 27 secondsTo install Python on Mac OS, you'll first need to install Xcode. So open up you App Store, search for Xcode, and then when you find the application, install it to your computer. This will take a few minutes. Once Xcode is installed, you can open up a web browser and then navigate to brew.sh.

Skip to 2 minutes and 52 secondsThis is the home page of Homebrew, which is a Mac package manager allowing you to install lots of different applications. To install Homebrew, copy the script that's on the home page here and then, open up a terminal. Here, I'm going to use Spotlight to search for terminal, and then the application opens up. In the terminal, you can paste in the link from the previous page, run this, and Homebrew will start to install. It will likely ask you for several confirmations and for your password at a couple of points as well. This might take some time, but eventually, Homebrew will install. With Homebrew installed in the terminal, you can now install Python by typing "brew install python3."

Skip to 3 minutes and 45 secondsThis will install Python 3 to your system. But if you have a look at your applications, you might find that Python 3 is not there. Or if it is, there'll be a big question mark over it. So to make sure that we can access Python IDLE form your apps, just type "brew linkapps" into the terminal. Once this is done, you can navigate to your apps and do a quick search for IDLE, and you'll find that IDLE 3 will be there. You can open it up and begin writing your Python code.

Skip to 4 minutes and 17 secondsMost distributions of Linux come with Python 3 already installed. However, you might like to install the IDE, IDLE, to go along with your Python 3 installation to make coding a little easier. So open up a terminal. And then in your terminal, type "python3" to check whether you've got Python installed. And if you get the prompt like this, that means it's installed correctly. You can type Exit with an open closed brackets to kill the Python 3 process. Now we're going to install IDLE by first, updating our package manager by typing "sudo apt update," and then typing in your password. Then once your package manager is updated, you can type "sudo apt install idle3," and this will install IDLE into your apps.

Skip to 5 minutes and 12 secondsNow that it's installed, going into your application menu and doing a search for IDLE will reveal the IDLE app, which you can click on to open up your Python 3 shell, where you can start your coding. Another option for using Python 3 on your computer is through a web browser. Navigating to trinket.io will take you to a website where you can do just this. In Trinket, you'll need to sign up in order to be able to save your code, so click on the Sign Up button. And I'm just going to sign in using my Google account.

Skip to 5 minutes and 51 secondsOnce you are signed in, you will be taken to a page where you can create a new Trinket. Creating a new Trinket will give you different options for different types of Python. Confusingly, you're going to want to choose just standard Python, as this is the free version. Now to make sure your code is interpreted as Python 3 code rather than Python 2 code, you can type hash bang, or hash exclamation mark, and then Python 3 in your first line of your programme. Then you can type code as normal, and it will run and play out in the shell.

Getting started with Python

Before you start learning anything about Python, you are going to need to have it installed on your computer.

Now, confusingly there are two different versions of the Python language: there is Python 2 and Python 3. So which should you learn? A quick search online will reveal that there is some controversy over which version of the language is best to learn when getting started. In the early days of Python 3, there was very little support for the language, and most code available on the web was written in Python 2. This resulted in a lot of people recommending new learners learn Python 2 rather than Python 3.

This is no longer the case however. Python 3 is now very well supported, and Python 2 will no longer be officially supported in a little over two years. If you’re going to learn how to program in Python, then you want to be using Python 3.

Let’s spend a little bit of time seeing how you can install Python 3 on each of the three major operating systems. Feel free to skip ahead to the operating system that is relevant to you.

Windows

On Windows, your first step is to open up your web browser. You can then navigate to www.python.org/downloads.

On the web page that opens up, you will see a button to install the latest version of Python 3. Clicking this button will download an executable file. Click on the .exe file to run it.

Python Install Dialogue Box

In the dialogue box that opens up, it is important to check the box to Add Python 3 to PATH. Then you can go ahead and click Install Now. The setup process will take a little bit of time.

Once the setup is complete, click on Done, and then you can close your web browser. Clicking in the start menu, you should now be able to find IDLE, which is a fairly good interactive development environment for beginners to use with Python.

macOS

To install Python on macOS, you will first need to install Xcode. Open up your App Store and search for Xcode, and then when you find the application, install it to your computer, which will take a few minutes.

Once Xcode has been installed, open up a web browser and navigate to brew.sh, which is the homepage of Homebrew, a macOS package manager that allows you to install a lot of different applications.

To install Homebrew, copy the script that is on the homepage:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Then open up a terminal window, paste in the copied text, and then press Enter. This will start the installation process for Homebrew — you may be prompted at various times for confirmations and your password.

Once Homebrew has installed, in the terminal window you now type:

brew install python3

This will install Python 3 to your system.

If you now have a look at your Applications you might find that Python 3 is not there, or there maybe a large question mark over the icon. To make sure that you can access Python 3 IDLE from your apps, go back to the terminal window and type:

brew linkapps

Now when navigating to your Apps or searching for ‘IDLE’, you’ll find that IDLE 3 will be there.

Linux (Debian-based distributions)

Most distributions of Linux come with Python 3 already installed, however, you might like to install the interactive development environment IDLE to go along with your Python 3 installation to make coding a little easier.

Open up a terminal window and type:

python3

If you see a prompt that looks something like this:

Python 3.6.4 (default, Dec 19 2017, 05:36:13) 
[GCC 6.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

That means Python 3 is installed correctly. Just type exit() to kill the Python 3 process.

To install IDLE, update your package manager and install IDLE by typing the following into the terminal window:

sudo apt update
sudo apt install idle3

This will install IDLE into you Apps, and you should be able to search for it in your Application menu.

Web browser

Another option for using Python 3 on your computer is using your web browser. Opening a web browser and navigating to trinket.io will allow you to do just this.

On Trinket, you will need to sign up in order to be able to save your code. You can create your own account or use a login service.

Once you are signed in, you will be taken to a page where you can create a New Trinket. Clicking on the button will give you different options for different languages. Confusingly, you’re going to want to choose standard Python, as this is the free option.

Python Install Dialogue Box

To ensure that your code is interpreted as Python 3 rather than Python 2, type the following on the first line of your program.

#!python3

Then you can type code as normal, and it will run in the adjacent frame (or shell).

Share this video:

This video is from the free online course:

Scratch to Python: Moving from Block- to Text-based Programming

Raspberry Pi Foundation

Contact FutureLearn for Support