1

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"
Ferdinand
  • 241
  • 3
  • 12
  • What's in your Python script? – peacemaker Jul 02 '12 at 15:37
  • 1
    Yes 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 Jul 02 '12 at 15:38
  • Also, you should name your Python scripts with a .py extension... – user1413793 Jul 02 '12 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 Jul 02 '12 at 15:40

2 Answers2

2

Good 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?

Community
  • 1
  • 1
xlarsx
  • 981
  • 1
  • 9
  • 8
  • 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. – Ferdinand Jul 02 '12 at 15:42
2

If you have the Python executable in your path, you'd call your script like:

python C:\Python\Script.py
peacemaker
  • 2,541
  • 3
  • 27
  • 48
  • 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) – Ferdinand Jul 02 '12 at 15:46
  • 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.py` – peacemaker Jul 02 '12 at 15:50