[Tutor] Running python from windows command prompt

Dave Angel davea at davea.name
Wed Apr 10 14:50:44 CEST 2013


On 04/10/2013 08:32 AM, Arijit Ukil wrote:
> I like to run a python program "my_python.py" from windows command
> prompt. This program ( a function called testing) takes input as block
> data (say data = [1,2,3,4] and outputs processed single data.
>
> import math
>
> def avrg(data):
>     return sum(data)/len(data)
>
> def testing (data):
>     val = avrg(data)
>     out = pow(val,2)
>     return out
>
> I am using python 2.6. My intention is to run from windows command
> prompt as
>
> python my_python.py 1 3  2
>
> However I am getting error: No such file in the directory, Errno 21
>
> Pls help.
>

Interesting error message.  So it really doesn't identify what file, nor 
in what directory it's looking?

Windows will search the path for python, but it's up to you to specify 
the right directory for data files.

Presumably that indicates that my_python.py is not in the current 
directory.  Is it?

If that's the problem, you can either change to the right directory (cd 
  mysource)  or you can give an explicit path on the command line

python path\to\my_python.py  1 3 2

It's frequently useful to paste the relevant portion of the commandline 
into your message.  Don't paraphrase.

-- 
DaveA


More information about the Tutor mailing list