2

Possible Duplicate:
How to make python scripts executable on Windows?
Set up Python on Windows to not type python in cmd

I have a python script under windows. Each time, I need to run using python *.py.

Can I run just as *.py without specify python?

0

3 Answers 3

3

Do you want to run it from the command line or the desktop?

If you set the file association for .py files (this is usually done during the install) you should be able to just double-click on the .py file on the desktop to get it to run.

I don't know of a way to avoid typing python with the command line (and this if it's on the PATH already, otherwise one would have to specify the whole path to the python executable).

It would be nice if we could do something similar like under Linux/Unix with #/usr/bin/env python directive in the script, but I don't think this exists for Windows unfortunately.

You didn't specify what version of Windows you are running, but in case you are interested in assigning/changing file associations, here are Microsoft's instructions on doing that with XP. Very similar with other versions of Windows .. googling will bring up a bunch of hits for how to change file associations.

Sign up to request clarification or add additional context in comments.

2 Comments

I think if he wants to run it from the command line, then technically his question is if there's a way to specify file associations in the command line.
@AbhranilDas Yes, I think you are right
1

I can only refer from the Python doc's: http://docs.python.org/using/windows.html#executing-scripts

Comments

0

If you're looking to run it automatically from Windows, you could compile the code with py2exe, or you could write a batch file that ran the Python file in question.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.