This happens because the Windows operating system does not know where to find Python when you type python
into a command window as shown in the following screenshot:
There are three ways around this problem:
Type in the full pathname for both python and the target program we want to run. In this example, we have used the python program named
entry_box_1.py
. It has been stored inside a folder namedconstr
as described in the first example Running a Shortest Python Program in the first chapter. The following screenshot shows the command-line dialog.george
is the name of the user logged into Windows.Work inside the
Python27
folder. What we do iscd..
andcd..
again. Thencd
into folderPython27
. Then we can just typepython \constr\entry_box_1.py
into the command-line as shown in the following screenshot:Change the Windows system variable that informs Windows where to search for executable files. We do this by typing
set PATH=%PATH%;C:\Python27
into the command-line window. From now on, we can just typepython \constr\entry_box_.py
from within any folder. The dialog that achieves this is shown in the following screenshot: