Dark theme

Intro to running Python


If you got that working, great! (still read the following!) If you didn't, that's not at all unusual! There's a few of things that might be wrong:

1) You might have mis-typed the program. Go through and make sure it is typed as suggested, especially that there's no spaces in front of the text and the capitalisation is correct.

2) The other thing is that you may have used the wrong capitalisation in either the filename or the command prompt command. Check these. This matters less on Windows, but you should try and get it right anyhow as it matters for some languages and operating systems.

3) Check that the text editor hasn't saved the file as HelloWorld.py.txt. On Windows, check the file extensions aren't hidden (info).

4) You've installed Python 2 instead of Python 3. Try changing the script to print "Hello World". If that works, you're on Python 2. Uninstall Anaconda and install the Python 3 version.

5) Anaconda hasn't installed properly – try reinstalling it *and* reopening the command prompt/terminal.


It is worth making an important point at this point: the difference between people who become programmers and those who don't is very clear: it is about how you respond to problems.

Beginners imagine that coders sit down, type perfect code, run it, and the job is done. This isn't what programming looks like at all!

Programming is people sitting down, writing code, and then spending between 50 and 80% of their time *fixing* the code so it works. This is because computers need talking to very carefully – they're just a box of wires, so they can't do all the guessing and interpretation humans can do.

You need:

  • all the spelling correct;
  • all the capitalisation correct;
  • all the punctuation correct and it the right place;
  • in Python, all the spaces between text and the left margin correct (as indents mean something);
  • all the program logic correct (for example, not trying to read a file that doesn't yet exist).

As human beings, we're not use to this, and everyone, *EVERYONE*, makes mistakes – this is a good thing: if you didn't make mistakes, you'd be a robot, not a human. All that happens when you become a good programmer rather than a beginner is you spot the simple mistakes earlier, and make harder mistakes because you try crazier stuff.

The difference between people who succeed at coding and those who drop programming is how relaxed and accepting of their bugs people are. People who struggle think that bugs reflect how bad they are at coding (rather than how good a human being they are); coders, on the other hand, welcome problems – they delight in having to solve problems and welcome the challenge. Once you get to this point, you're a coder.


Try making some errors in your program (mis-spelling print; changing the punctuation), then re-save the file (don't forget this!), and re-run it. See what messages it gives you. We'll shortly look at some techniques for identifying bugs, but, for now, getting familiar with the messages from the interpreter is useful.


Now we'll look at another way of running Python: interactively.

  1. Start
  2. Get the software
  3. Writing our first program: running at the command line
  4. Debugging
  5. IDEs: IDLE and Spyder <-- next
  6. Jupyter Notebook