Dark theme

Issue: Getting it working
Key skill: problem decomposition


Again with the errors! We still have this:
The system cannot find the path specified

Now we know the Python works, so let's look at our list again:

  1. Our typing of the shell script name.
  2. The python script that is run.
  3. The shell script itself.
  4. The Python interpreter.
  5. The shell itself.
The next simplest thing is to look at the shell script. If you open it up, you'll see this for the bat:
"c:\Program Files\python3.1\python" HelloWorld.py
And this for the sh:
\opt\bin\python3.1\python HelloWorld.py

What the coder has done is written in the full path to the Python interpreter, rather than just saying python HelloWorld.py. The Python interpreter is a piece of software, like any other. It sits in a directory on the file system, like any other. There's nothing to stop you running it by giving the full path to it through the file system (provided the path is right), indeed, it seems a bit odd we can just type python HelloWorld.py and the computer knows where it is.

Just typing the name works because the Python directory is added to the computer's PATH when it is installed. PATH is what is called an "environment variable": a value stored as a variable by the operating system, and made available for use across the system. PATH stores the location of all the important software directories, such that if you type the name of the software you want, the operating system will search all the PATH directories for it. Now, you can manually add stuff to the PATH if you have admin rights to a machine (Windows; Mac/Linux), but this coder was apparently having trouble with theirs. Unfortunately, their path to the interpreter is not the same as ours, so the machine isn't recognising it. The solution is to remove the path and let the computer track down Python. Adjust the file so it says:
python HelloWorld.py
You should now be able to run the file!

In the last part, we'll look at other options for the things on the list.


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