Ok so I got python to run in command prompt I just can't figure out the syntax to call scripts from it. So my file is in c:\python\script so I've been calling like this;
"C:\Python\Script"
but it doesn't anything and returns
""File<stdin>", line 1"
-
What's in your Python script?peacemaker– peacemaker2012年07月02日 15:37:49 +00:00Commented Jul 2, 2012 at 15:37
-
1Yes because you are only listing a file, not telling windows what to do with that file. I don't own windows but I'd assume you would have to somehow tell it you are running this program with the Python interpreter. However, Windows does not have a bash terminal so I don't know how its done. You can try downloading a bash terminal and using that.user1413793– user14137932012年07月02日 15:38:10 +00:00Commented Jul 2, 2012 at 15:38
-
Also, you should name your Python scripts with a .py extension...user1413793– user14137932012年07月02日 15:38:32 +00:00Commented Jul 2, 2012 at 15:38
-
The scripts are in .py ext. The script is a simple program to sort contents of files, I just don't know the syntax to call in the python window from command prompt.Ferdinand– Ferdinand2012年07月02日 15:40:11 +00:00Commented Jul 2, 2012 at 15:40
2 Answers 2
If you have the Python executable in your path, you'd call your script like:
python C:\Python\Script.py
answered Jul 2, 2012 at 15:40
peacemaker
2,5914 gold badges28 silver badges49 bronze badges
Sign up to request clarification or add additional context in comments.
2 Comments
Ferdinand
I have the executable in the path and have sucesfully ran python on the command prompt, the only problem is calling the script which is in another folder; PYTHON 2.7 (in this path "C:\python27\python) my script is in (C:\python\script.py)
peacemaker
You can call the script as shown in my answer by passing the entire path into the python command. Alternatively, you can navigate to the location of your script
c:\python and then run python script.pyGood day,
python script.py arg1 arg2 argN
If the python interpeter isn't in the PATH variable you can set it with: Setting a system environment variable from a Windows batch file?
answered Jul 2, 2012 at 15:39
xlarsx
9911 gold badge9 silver badges8 bronze badges
1 Comment
Ferdinand
Well I tried "python script.py" but it doesn't run, is it because my script is not in the same folder? Also the script takes in no arguments since they are set within the script.
Explore related questions
See similar questions with these tags.
lang-py