How to run a .py file in windows command line?

MACEE

I have written a simple python program using IDLE to run it from command line. I don't have permission to save .py file in python directory (C:\program files\python33) so I saved it to C:\Pyscripts.

Also python was already been added to the PATH and I can run a simple print ("Hello") in command line. I have saved this line into a py file and Now I want to run it from command prompt but I have faced different errors! I have searched and tested different ways but they didn't work!

any suggestion?

Thanks.

lxx
  1. Start cmd.exe
  2. cd C:\Pyscripts
  3. python filename.py

For basics like print 'hello', you don't need any library import statements but for slightly more complex things you will.

Which python do you have installed?

  1. You don't want to save files in c:\program files under windows. That isn't a good practice. Setting up a dev directory like you did or under your user directory is a much better option.

  2. Have you added python to the path setting? If you start a command prompt (cmd.exe, not IDLE and type python, what do you get? If you haven't set the python path, see http://docs.python.org/2/using/windows.html or http://www.katsbits.com/tutorials/blender/setting-up-windows-python-path-system-variable.php. Just update the settings to the version of python you are using e.g c:\python27.

  3. Get a text editor instead of using IDLE. textpad, textedit, vim, emacs ,context, geanie, sublime, and many many more. Or get an IDE. Aptana's studio 3 is easy to use and free (eclipse with plugins already installed) or the free community version of pycharm.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to run a python file (.py) from the windows command-line without having to type python first?

From Dev

How to run a .py file through a batch file using Command line

From Dev

How To Run A Python File From Windows Command Line

From Dev

How to run .js file from a command line on windows?

From Dev

How to run php file through command line?

From Dev

How to run Windows SDK Command Prompt from command line?

From Java

How to create an empty file at the command line in Windows?

From Dev

Run JavaScript in a Windows Command Line

From Dev

How to run a windows .bat script with wine from command line?

From Dev

How to run regex find and replace using windows command line

From Dev

how to run a django python file from command line

From Dev

How to run tests in a playlist file from mstest command line

From Dev

How to run .exe executable file from linux command line?

From Dev

How can I run a ruby file in command line from Java?

From Dev

How to run .exe executable file from linux command line?

From Dev

Dart : How to set the preamble file to run on the command-line?

From Dev

How can I run a specific line as a command in a text file?

From Dev

How to run batch file command line argument on another server?

From Dev

How do I run .c file from the command line

From Dev

Run .py file until specified line number

From Dev

How to run AppImage on the command line

From Dev

How do you configure PyCharm to run py.test with command-line options like -s?

From Dev

How to run a localhost:8000/script.py in command line without open in browser?

From Dev

How to run a script, command or exe file, when login windows?

From Dev

How to execute jar file with a external dependency using command line on Windows?

From Dev

How to add optional command line parameter in bat file ( windows )

From Dev

How to parse a JSON file to variables with the windows command line?

From Dev

Windows: How to read command-line options from external file?

From Dev

How to add optional command line parameter in bat file ( windows )

Related Related

  1. 1

    How to run a python file (.py) from the windows command-line without having to type python first?

  2. 2

    How to run a .py file through a batch file using Command line

  3. 3

    How To Run A Python File From Windows Command Line

  4. 4

    How to run .js file from a command line on windows?

  5. 5

    How to run php file through command line?

  6. 6

    How to run Windows SDK Command Prompt from command line?

  7. 7

    How to create an empty file at the command line in Windows?

  8. 8

    Run JavaScript in a Windows Command Line

  9. 9

    How to run a windows .bat script with wine from command line?

  10. 10

    How to run regex find and replace using windows command line

  11. 11

    how to run a django python file from command line

  12. 12

    How to run tests in a playlist file from mstest command line

  13. 13

    How to run .exe executable file from linux command line?

  14. 14

    How can I run a ruby file in command line from Java?

  15. 15

    How to run .exe executable file from linux command line?

  16. 16

    Dart : How to set the preamble file to run on the command-line?

  17. 17

    How can I run a specific line as a command in a text file?

  18. 18

    How to run batch file command line argument on another server?

  19. 19

    How do I run .c file from the command line

  20. 20

    Run .py file until specified line number

  21. 21

    How to run AppImage on the command line

  22. 22

    How do you configure PyCharm to run py.test with command-line options like -s?

  23. 23

    How to run a localhost:8000/script.py in command line without open in browser?

  24. 24

    How to run a script, command or exe file, when login windows?

  25. 25

    How to execute jar file with a external dependency using command line on Windows?

  26. 26

    How to add optional command line parameter in bat file ( windows )

  27. 27

    How to parse a JSON file to variables with the windows command line?

  28. 28

    Windows: How to read command-line options from external file?

  29. 29

    How to add optional command line parameter in bat file ( windows )

HotTag

Archive