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:
- Our typing of the shell script name.
- The python script that is run.
- The shell script itself.
- The Python interpreter.
- The shell itself.
"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.
- Start
- The problem
- Decomposing the problem
- Testing the parts
- Solving the issues 1
- Solving the issues 2
- Solving the issues 1
- Final points <-- next