473,386 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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?
Feb 16 '20 #1
4 4045
SioSio
272 256MB
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.
Feb 17 '20 #2
Ishan Shah
47 32bit
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\UserName\Documents which has following code :

Expand|Select|Wrap|Line Numbers
  1. print('Hello! Welcome to my first Demo')
Then for run the demo.py Open Terminal and Change current working directory to C:\Users\UserName\Documents using the cd command

c:\Users\UserName\Documents>python demo.py
Hello! Welcome to my first Demo

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

Expand|Select|Wrap|Line Numbers
  1. Hello! Welcome to my first Demo
  2.  
If you want to run programs stored in a file, then only double click on .py file to run the program
Apr 24 '20 #3
Run the Python command-line interpreter, under your OS of choice,
Open Command line: Start menu -> Run and type cmd.
Type: C:\python27\python.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.
Apr 29 '20 #4
On command prompt and go to the directory where python file is stored and type and enter
Expand|Select|Wrap|Line Numbers
  1. python "name of python file".py 
May 8 '20 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Danny De Koster | last post by:
Hi all, I'm really a newbie. How can I trap (read in my program) the parameters which where giving at the launch of the my program? thanks for any tips Danny
0
by: Jeffrey Barish | last post by:
I have been developing a Python program with two intercommunicating (using sockets) parts, one of which runs on a desktop and the other on a PDA. For ease of development, I developed them both on...
1
by: Ernesto | last post by:
how do you self terminate a python program from within the code? something similar to exit(0) in C. I think the problem is that I'm using subprocess and popen to launch a '.exe' file and...
1
by: sylsau | last post by:
Hello, I wrote a JAVA program which uses the JAVA API JDOM 1.0 (of this site www.jdom.org) I put the archive jdom.jar in the directory /usr/share/java/jdom.jar and I added this path in the...
3
by: gopython | last post by:
The python program usually terminate itself by the end of the file. Is there anyway to control how the python program should terminate? For example: import os os.system ('notepad.exe') #...
8
by: =?iso-8859-1?B?QW5kcuk=?= | last post by:
I would like to find out how I can launch an independent Python program from existing one in a cross-platform way. The result I am after is that a new terminal window should open (for io...
1
by: Jim Langston | last post by:
Windows. Situation: Using a Python program called OpenRPG. I have a program that displays form data (a character sheet) in C++. I am able in the C++ program to build a string and copy it into the...
8
by: karthikbalaguru | last post by:
Hi, One of my python program needs tkinter to be installed to run successfully. I am using Redhat 9.0 and hence tried installing by copying the tkinter-2.2.2-36.i386.rpm alone from the CD 3 to...
1
by: =?ISO-8859-1?Q?Andr=E9?= | last post by:
Hi everyone, I'd be interested in hearing suggestions as to the "best" way to drive a Python program step by step from another application. Details: --------- I have implemented a "Robot"...
4
by: maximus tee | last post by:
hi all, i wrote a simple GUI with 2 buttons. Button1 is to launch another program. Button2 is to run test. When I click Button1, it will launch another program. After launching the program, my...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.