How to install Python

Beginners Guide to Programming – Install Python

Before we move on to anything else, we need to get ourselves set up so we can actually start programming. So in this tutorial we are going to learn how to install Python and an environment called IDLE. At the end, we’ll open our command line, and make our first program.

This tutorial is part of a series. To see the previous tutorial click this link: Introduction to Programming

Topics Covered

  • Installing Python
  • Running Python in the Command Line
  • Executing a Python program.

How to Install Python

To install Python on your computer it’s pretty straight forward. As long as you’ve installed software before you shouldn’t need this tutorial. But we’ll go through it step by step for those who feel uncomfortable.

First thing you need to do is copy and paste this URL into your browser: https://www.python.org/downloads/

Depending on what year your reading this the screen might look very different from the screenshot below. However there should still be a big button to download the latest version. In this tutorial we’ll be using 3.4.3.

Install Python

You can go ahead an download the latest version even if it’s newer than 3.4.3. We will be looking at how to read documentation in a later tutorial, so if there are any changes to Python, it’ll be easy enough to translate the minor differences.

Before moving forward, I’ll just make a mention of the version numbers. By convention the first digit in the version number represents the most significant changes to the language. The second digit represents minor changes, and the last digit represents micro changes, which are usually bug fixes. If your super interested in reading more about it, click/tap the link: https://docs.python.org/2/faq/general.html#how-does-the-python-version-numbering-scheme-work 

So the reason I bring this up is that at the time of writing this article there are two popular versions of Python being used. They are commonly referred to as Python 3, and Python 2.

I’ll be using Python 3 for this tutorial, so if you get stuck and are trying to find help on Google, your keyword is Python 3. You’ll find a lot more information this way than using your specific version number as a search query.

OK, now download the latest version for Python, and make sure you choose the one for your operating system. I just save it to my desktop, so I can easily delete it after it’s installed. Once the download is complete, click on the file and open it.

Here’s what it looks like when open the setup file on my Windows 8.1 PC.

Python Install Wizard

You’ll notice that mine comes up with different options because I already have Python installed. For the purpose of this tutorial I’m going to uninstall it, and then walk you through the steps.

Here is what the installer looks like after uninstalling Python from my computer.

Python Install Wizard

Select whichever option works for you. For me, I’m just going to check ‘Install for all users’.

Next I’m asked to select a directory. For me the default is fine, so I’ll just click next.

Default Directory

Next I get a “customize Python” screen. When I scroll down to the bottom of the options I see one that says “add Python.exe to path”. This option is so that if we use Python in the command line, we can call it without going to the path destination. This just means I don’t have to type “cd C:/python34/python” into my command line to run Python. Instead I can just type “python” from any directory.

Add Python.exe to Path

Anyways, I want Python in my path. We won’t be using the command line too much, but you should add it to your path so it’s easier to check if it installed properly later. Just click the red and then select “will be installed on local hard drive”.

Now you can click next, and let Python install. Once it’s all done you click “finish”. And you’re done! You now have Python installed on your computer.

You also should now have a program called IDLE on your computer now too. Later this is were we are going to be writing our code. IDLE is a type of program called an IDE (Integrated Development Environment) which makes programming a little easier for developers. We’ll learn more about what an IDE is, and more about IDLE in the next tutorial.

Running Python

Next let’s see if Python installed correctly. To open your command line on Windows, just click the start button and start typing “cmd”. Once cmd.exe comes up click it or hit enter. On Windows XP and Vista, I think you have to click “run” first before you start typing.

For Mac users, navigate to /Applications/Utilities and doible-click on Terminal. If it doesn’t work try doing a google search: how to open command line in mac [your version].

If you’re running Linux, you probably already know how to open the command line. If not, do a google search for your specific distribution, and it should only take a second to figure it out.

Once you get into your command line, just type python.

Here’s what it should look like.

Check Python install in command prompt

 

Don’t worry if your cmd doesn’t look exactly like mine. What’s important is that you get a version number followed by some information and then a line that looks like this: >>>

If you see “>>>” that means you are now running Python, and you can begin typing commands. This is called the Python interpreter, and we will learn about what that means in the next tutorial.

First Program.

This example is going to show you how simple and easy Python can be to get started. What I’m about to show you is a lot more complicated to achieve in many other languages. Our first program will be very simple and unimpressive compared to what we’ll do later on, but we all have to start somewhere.

For now just type the following:

print('hello world')

If you typed this exactly as shown above, and hit “enter” you should have gotten the words “hello world” printed out in your console.

hello world python

Congratulations! You just wrote your first program and it was executed by a computer successfully! Don’t worry if what you just did confuses you. It’ll make sense after the next tutorial.

In the next tutorial we’re going get out of the command line and learn what an IDE is. We are going to use an IDE called IDLE (included with the Python installer). We’re also going to learn what an interpreter is, and what a script is. We will then write our first Python script using IDLE and execute it in the interpreter.


If you got everything to work correctly, congratulations! Feel free to ask questions in the comments below, I’d love to help you out.

Also, if you spot any errors in this tutorial please let me know!

One thought on “Beginners Guide to Programming – Install Python”

Leave a Reply