How do i run python scripts!!!!!!

I have just installed python 2.5 but i don't know how to run python scripts in the command prompt. PLEASE HELP
closed account (3qX21hU5)
First off I would go and get Python 2.7 since that is the latest version for the 2's.

Next when you installed the Python Interpreter it should have installed a program called IDLE along with it. This is there out of the box Text Editor that you can use, though I would install another like Sublime Text to use,

Anyways to run Python scripts just open the script with IDLE then go Run->Run Module or press f5. This will run the script.

If you want to launch your script from the command prompt (IE Windows CMD) just navigate to the folder your script is in then then just type the scripts file name (Like or something along those lines.

But you have to make sure that your Python Interpreter is in your PATH. If it isn't you can add it easily by doing this.

Open up your command prompt in windows and type in this

set PATH=%PATH%;"The Path to your Python folder here"

Usually you will find the Python Interpreter in thsi destination C:\Python27 (I have Python 2.7). So to add it to my PATH variable I would type this into the CMD set PATH=%PATH%;C:\Python27

Once you have it in your PATH variable you should be able to compile from the command line.

Here is a example of me compiling a script

Microsoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights reserved.

C:\Users\Brandon>cd desktop/python


Then the script output below.

Let me know if you have any more troubles.
Last edited on
heya sam dhillon i thought might like this vids

vivet ramchen explains it deeply from the basics of python language then applies to infosec. etc in a very pretty manner that everone can understand u should hold a copy of this book below as well i started with this then studied the python tutorial by guido van rossem but i felt like i always missing something so i got to learn C then i will switch to python in the future when i need it

and you should check the ##python channel on freenode they are pretty helpfull community
Note that invoking a Python script like this


assumes that the file association (.py -> python.exe) has been configured. This should have been done by the Python installer, if you used one. But if you installed Python using just unzip and copy, then you'd have to set this assocation up yourself.

The equivalent long form of "" is (assuming it's on the path)


Topic archived. No new replies allowed.