Launch Python program on PC

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • reblark
    New Member
    • Feb 2020
    • 1

    Launch Python program on PC

    I just wrote a small program that launches on a Mac by setting the "open with" file parameter to python launcher. How can I get the same program to run installed on a Windows desktop?
  • SioSio
    Contributor
    • Dec 2019
    • 272

    #2
    On Windows, double-click a file with the extension .py to run the program.
    If you did not select "Add Python X.X to Path" when installing python, by default the py.exe (Python Launcher) is associated with the .py file instead of python.exe.

    Comment

    • Ishan Shah
      New Member
      • Jan 2020
      • 47

      #3
      In windows, there is no need for any Python launcher.
      You can run python programs in two ways in windows, First by typing commands directly in a python shell or run program stored in a file.
      But most of the time you want to run programs stored in a .py file.

      Like a file named demo.py is saved in your documents directory i.e C:\Users\UserNa me\Documents which has following code :

      Code:
      print('Hello! Welcome to my first Demo')
      Then for run the demo.py Open Terminal and Change current working directory to C:\Users\UserNa me\Documents using the cd command

      c:\Users\UserNa me\Documents>py thon demo.py
      Hello! Welcome to my first Demo

      If everything is ok then you will get the following output :

      Code:
      Hello! Welcome to my first Demo
      If you want to run programs stored in a file, then only double click on .py file to run the program

      Comment

      • lewish95
        New Member
        • Mar 2020
        • 33

        #4
        Run the Python command-line interpreter, under your OS of choice,
        Open Command line: Start menu -> Run and type cmd.
        Type: C:\python27\pyt hon.exe.
        Note: This is the default path for Python 2.7. If you are using a computer where Python is not installed in this path, change the path accordingly.
        Last edited by Rabbit; Apr 29 '20, 06:03 PM. Reason: External links removed

        Comment

        • hussainmujtaba
          New Member
          • Apr 2020
          • 13

          #5
          On command prompt and go to the directory where python file is stored and type and enter
          Code:
          python "name of python file".py

          Comment

          Working...