[Tutor] python: can't open file 'test.py' : [Errno 2] No such file or directory

Pierre Dagenais pierre.dagenais at ncf.ca
Wed Oct 1 21:48:25 CEST 2008


>> If you're right about having to give the full path, and I suspect you 
>> are, Then this means that python knows to search the currennt working 
>> directory for  the file to execute, but nowhere else.
>
> Correct, just like every other program.
> If you run notepad foo.txt notepad will open a new foo.txt
> in the current folder it will not search your drive to find some
> other foo.txt that you created prevbiously.
> Why would python be any different?
I didn't realize other program were also behaving that way, I don't work 
much with the command prompt anymore :-)
>
> The trick to do what you want is not to execute python but
> to execute the script and allow the OS to associate Python
> with it.
That is what I was missing, C:\test.py will execute.
>
> So either just type the script name into the prompt (assuming
> it is on the PATH) or double click in explorer and Windows will
> find Python itself.
>
> HTH,
It sure does, thanks everybody for the great replies,


More information about the Tutor mailing list