How to call python script in other folder without prepending `python`?
5,997
You're using *nix path delimiters. Use ..\myscript.py, not ../myscript.py. The Python program is smart enough to accept either.
C:\Program Files (x86)\Notepad++\localization>../notepad++.exe
'..' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files (x86)\Notepad++\localization>..\notepad++.exe
[ this one launched the app as expected ]
Related videos on Youtube
Author by
Rabarberski
Updated on September 18, 2022Comments
-
Rabarberski over 1 year
I have a small (self-written) python script located in, let's say,
C:\dummy\myscript.py
. In my Windows 7 terminal, I can call this script with either one of the following three commands. They all work.C:\dummy>python myscript.py C:\dummy>myscript.py C:\dummy>myscript
I understand that the latter two commands work out fine because of the correct
assoc .py=Python.File
setting on my system(see here)However, when I am in another folder, say,
C:\dummy\subfolder\
, it only works when I prepend the python executable.C:\dummy\subfolder>python ../myscript.py C:\dummy\subfolder>../myscript.py <-- doesn't work '..' is not recgnized as an internal or external command, operable program or batch file. C:\dummy\subfolder>../myscript <-- doesn't work '..' is not recgnized as an internal or external command, operable program or batch file.
Why doesn't it work in the other two cases?
-
Rabarberski about 10 yearsAh rats, of course!
-
Rynant about 10 years@Rabarberski Just a note that this is the case for CMD; PowerShell can take either delimiter.