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"
4
  • What's in your Python script? Commented Jul 2, 2012 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. Commented Jul 2, 2012 at 15:38
  • Also, you should name your Python scripts with a .py extension... Commented 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. Commented Jul 2, 2012 at 15:40

2 Answers 2

2

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

python C:\Python\Script.py
Sign up to request clarification or add additional context in comments.

2 Comments

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

1 Comment

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.