How to execute a saved script in command line?


Please leave the following link in the post so we can find the unit module, else replace it with a link to the exact lesson:

Strings and Console Output


you can type: python, where scriptname is the name of your script, and you are in the same directory.


what if the script is in a different directory, is there a direct command


then you have to do path\to\ where path\to is an absolute or relative path to the script.

if you use *nix based system, the path should use forward slashes, backward slashes is for windows


can you give an example, for windows, what exactly to type. suppose the script is in d drive


you first need to navigate to d:, CMD opens in C: by default, so scripts would be easier to have on the c drive.

you first need to switch to D drive:


then from there you could do:

assuming d: lands you in the right directory, this depends what on the D: drive. I moved my home directory there, so for me, it opened D:\myuser where myuser is my name, which i am not going to share. Not sure why windows put me there and not in in D:\

is the script in D without any subfolders? then it would be:

cd \


in cmd, it is not working. it says that python is not a recognizable command. are we talking about the command line, that comes with the software? i am using windows and python 2.7


python needs to be installed of course, and inside PATH for cmd to find it.

it could be that the command is python2, press tab twice to see auto complete options


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.