Dark theme

Issue: Getting it working
Key skill: problem decomposition


So, what if that didn't solve it? Well, the first thing would be to check we've spelt everything correctly, with the right capitalisation.

  1. Our typing of the shell script name.

This is first on our list not just because it is the simplest to check, but also because it accounts for 90% of problems.

Associated with that is checking we're in the right directory. You'd be surprised how easy it is to open a file, work on it, try and run it, and find this error:
python: can't open file 'HelloWorld.py': [Errno 2] No such file or directory
99 times out of 100, you're just not in the same directory in the command prompt as the file you're trying to run. One of the other times you'll see this is if the text editor you're using has saved the text file as, for example, HelloWorld.txt or HelloWorld.py.txt. This can be quite hard to spot on Windows machines, as by default they hide file extentions. See how to unhide file extensions.

  1. The Python interpreter.

In terms of the python interpreter itself, the most common issue is using code that demands Python 2, when you're using Python 3, or vice versa. Often this is a library that someone else has written and hasn't updated to 3. Sometimes the interpreter will tell you, but often it will just report syntax errors. If you're unsure the version that is running on a machine and/or want to check Python is running at all, you can check both by typing:
python --version
It is possible to install more than one version of Python at the same time; the computer will default to whichever is listed first in the PATH and you'll have to type the full path to the other to use it. Infact, a number of the components in Python 3 in the standard install have aliases, so you can type python3 isntead, but Anaconda doesn't do this. Instead Anaconda has a more sophisticated system for switching, though generally it is much simpler to stick to 3 and the associated libraries.

If the interpreter isn't working, then try (in this order):

  1. closing the command prompt and reopening it: this will refresh any environment variables like PATH that might have been corrupted;
  2. restarting the machine: this will free up any resources that poorly written programs might have grabbed control of and not freed up (that's a thing: if you use Windows you'll recognise the experience of not being able to delete some file because something is using it). There's a good reason IT help desks ask have you tried turning it off and on again?;
  3. Update Python and/or Anaconda. If you have the standard Python, you can update it (but not from 2 to 3) using:
    pip install pip --upgrade
    pip install python --upgrade

    (pip is Python's system for installing and updating libraries and other software)
    If you have Anaconda, use:
    conda update conda
    conda update anaconda

    Restart your machine afterwards, just to make sure.

If none of these work, you may have to uninstalling and reinstalling Anaconda.

  1. The shell itself.
In general, one of these will work. If it doesn't and you're on a standard machine, something has gone very wrong and you might have to repair the operating system. If you're using a virtual operating system (for example, running Windows inside a Mac) it may be a PATH problem – find the location of the intepreter and type the full path as in the broken shell scripts we saw. If that doesn't work, switch to your standard operating system.


So, that's a walkthrough of the major issues with getting Python working. Hopefully you won't have any of them, so the take-away message is really about problem decomposition and a resilient spirit. Remember, the key is to work out what all the components in the issue are, and to test each in order of ease and/or likeliness. Stuff goes wrong: coders spend most of their time debugging. The key is a can-do attitude and a logic approach.

With that in mind, here's a problem for you to solve. As before, download the zip file, unzip it, and get the shell scripts working: HelloWorld2.zip.


  1. Start
  2. The problem
  3. Decomposing the problem
  4. Testing the parts
  5. Solving the issues 1
  6. Solving the issues 2
  7. Final points