473,700 Members | 2,602 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to make python scripts .py executable, not bring up editor

From command Prompt, i type in a script, "tryme.py".

This, instead, brings up PythonWin editor and Interactive Window.

Path variable is "C:\Python2 4". (I need Python 2.4 installed, not 2.5)

How do I make it so that the script runs?
Jul 7 '08 #1
9 2441

korean_dave wrote:
>>From command Prompt, i type in a script, "tryme.py".

This, instead, brings up PythonWin editor and Interactive Window.

Path variable is "C:\Python2 4". (I need Python 2.4 installed, not 2.5)

How do I make it so that the script runs?
--
http://mail.python.org/mailman/listinfo/python-list
=============== =============== ========
I get tired of Microsoft jerking me around too. Rather than spend hours
trying to undo somebody's reorganizing my system preferences I just
ignore them completely.

py tryme is how I do it.

py.bat is a file placed in a directory listed in PATH in autoexec.bat.
Edit autoexec.bat to include directory you put it in and reboot system
or it won't find it. something like: PATH=.;c:\py-stuff;[anything
already listed] Don't forget the semicolons.

The . (period) up front means look here first. here being where ever you
are when you issued the command. (The pRESENT wORKING dIRECTORY :-) The
c:\py-stuff (fix to suit yourself and make sure it exists) is where you
can put your efforts to be called at your leisure. Your .py files you
write and use. Even the py.bat can go there.

(Short note: Microsoft usually does look in pwd first. But good form
dictates being specific.)

contents of py.bat:
=============== =========
rem name: py.bat
@echo off
c:\Python24\pyt hon %f.py make it fit your path
rem end of file
=============== =========

This way - you get what you expect, when you expect it, & nothing else.
Yeah - dumb, but it works! I have one similar for each of my compilers.
They contain the whole command line switches stuff as well as things
like remove old stuff before trying to over write with new since MS can
be temperamental about that.

Easiest way in the world to give it the finger and make it behave.

Steve
no******@hughes .ney
Jul 8 '08 #2
korean_dave wrote:
From command Prompt, i type in a script, "tryme.py".

This, instead, brings up PythonWin editor and Interactive Window.

Path variable is "C:\Python2 4". (I need Python 2.4 installed, not 2.5)

How do I make it so that the script runs?
Start-><right click>My Computer->Properties->Advanced->Environment Variables

in bottom pane "System Variables" add ";.py" to "PATHEXT"
Jul 8 '08 #3
On Jul 7, 4:56*pm, korean_dave <davidrey...@gm ail.comwrote:
From command Prompt, i type in a script, *"tryme.py".

This, instead, brings up PythonWin editor and Interactive Window.

Path variable is "C:\Python2 4". (I need Python 2.4 installed, not 2.5)

How do I make it so that the script runs?
type:

python tryme.py

or:

C:\Python24\pyt hon tryme.py

-- Paul
Jul 8 '08 #4
On Jul 7, 10:56*pm, korean_dave <davidrey...@gm ail.comwrote:
From command Prompt, i type in a script, *"tryme.py".

This, instead, brings up PythonWin editor and Interactive Window.

Path variable is "C:\Python2 4". (I need Python 2.4 installed, not 2.5)

How do I make it so that the script runs?
find a .py file in windows explorer. Right click it->Open With-
>Choose Program...
Now find your python.exe file (should be in c:\python24), select it,
and tick the box that says "Always use the selected program"

Iain
Jul 8 '08 #5
On Jul 7, 4:56*pm, korean_dave <davidrey...@gm ail.comwrote:
From command Prompt, i type in a script, *"tryme.py".

This, instead, brings up PythonWin editor and Interactive Window.

Path variable is "C:\Python2 4". (I need Python 2.4 installed, not 2.5)

How do I make it so that the script runs?
You need to add python.exe to your system's path. In Windows XP, you
need right-click "My Computer", choose Properties, and then the
Advanced tab. Click the Environment Variables button. Then go to the
System Variables section and double-click the Path entry (you may have
to scroll down to get to it).

Notice that everything in this list is separated by semi-colons. You
should be at the end of the list, so just put a semi-colon at the end
and then type C:\Python24

Then it should work. You'll probably need to restart your command line
window though, as it doesn't always take affect on open windows.

HTH

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org
Jul 8 '08 #6

OK- ;
In Windows use the Window Explorer and go find a something.py.
Right click on it and select Open With then Browse and go find your
Python24\python .exe and select it. Then check the box that says "Always
use this for..." and test it by closing/re-opening WinExplorer and left
clicking (or double clicking if so set) and it should attempt to run.
IF so then use the 'dos window' and try typing in just it's name.
ie... tryme.py this should attempt to run also. If not, check the
C:\autoexec.bat PATH line. It just might be that it has the unwanted
Python editor's path there. If so, consider putting your python24 path
BEFORE it. (Don't forget to re-boot after mods to autoexec.bat) If that
isn't the problem you might consider a complete scrub, reformat and
re-install of Windows and ALL your stuff. (Uggg!)

Don't be surprised if at some point it may "reset itself" back to it's
current bad behavior. The Python editor shouldn't unless it is
re-installed for some reason.

The use of the bat file ignores any 'self reset' nonsense by forcing the
desired action(s) by keeping Windows from wandering about. During the
development cycle a modified copy in the working directory can delete
program created files before (re)running script. This keeps Microsoft
from yelling it can't function because something is in it's way. And
hardcoding the file under development, along with any needed tokens,
simplifies the command line and the cycle.
( del any files created in this loop (one line each)
( drive:\path_to\ python pgm.py token tokens.....
( don't remember if pause or whatever - but give time to inspect screen
( preferred_edito r pgm.py

if in t.bat then t<cr tests it and returns you to edit.
Saves lots of typos, lowers anxiety, speeds up cycle, increases
confidence in progress.

NOTE: I use Linux and I do have a typo in my original reply.
USE %1 NOT %f in the .bat file. Sorry
^numeric one

Steve
no******@hughes .net
=============== =============== =============== =============== ===========

David Eynon wrote:
When my anyname.py runs, instead of executing the script, it opens up
the file within the Pythonwin text editor.
=============== =============== =============== =============== ===========
On Mon, Jul 7, 2008 at 9:00 PM, norseman <no******@hughe s.netwrote:
>korean_dave wrote:
>>>From command Prompt, i type in a script, "tryme.py".
This, instead, brings up PythonWin editor and Interactive Window.

Path variable is "C:\Python2 4". (I need Python 2.4 installed, not 2.5)

How do I make it so that the script runs?
--
http://mail.python.org/mailman/listinfo/python-list
============== =============== =========
I get tired of Microsoft jerking me around too. Rather than spend hours
trying to undo somebody's reorganizing my system preferences I just ignore
them completely.

py tryme is how I do it.

py.bat is a file placed in a directory listed in PATH in autoexec.bat. Edit
autoexec.bat to include directory you put it in and reboot system or it
won't find it. something like: PATH=.;c:\py-stuff;[anything already
listed] Don't forget the semicolons.

The . (period) up front means look here first. here being where ever you are
when you issued the command. (The pRESENT wORKING dIRECTORY :-) The
c:\py-stuff (fix to suit yourself and make sure it exists) is where you can
put your efforts to be called at your leisure. Your .py files you write and
use. Even the py.bat can go there.

(Short note: Microsoft usually does look in pwd first. But good form
dictates being specific.)

contents of py.bat:
============== ==========
rem name: py.bat
@echo off
c:\Python24\py thon %f.py make it fit your path
rem end of file
============== ==========

This way - you get what you expect, when you expect it, & nothing else.
Yeah - dumb, but it works! I have one similar for each of my compilers.
They contain the whole command line switches stuff as well as things like
remove old stuff before trying to over write with new since MS can be
temperamenta l about that.

Easiest way in the world to give it the finger and make it behave.

Steve
no******@hughes .ney
Jul 8 '08 #7
On Jul 7, 5:56 pm, korean_dave <davidrey...@gm ail.comwrote:
From command Prompt, i type in a script, "tryme.py".

This, instead, brings up PythonWin editor and Interactive Window.

Path variable is "C:\Python2 4". (I need Python 2.4 installed, not 2.5)

How do I make it so that the script runs?
sounds like you need to adjust the file association so .py files are
associated with python.exe
Jul 8 '08 #8
On Jul 7, 2:56*pm, korean_dave <davidrey...@gm ail.comwrote:
From command Prompt, i type in a script, *"tryme.py".

This, instead, brings up PythonWin editor and Interactive Window.

Path variable is "C:\Python2 4". (I need Python 2.4 installed, not 2.5)

How do I make it so that the script runs?
You can do this by editing the registry, but here is the general way
to click through chaning file associations:

Right click on any python file (*.py) and choose "Open With" from the
context menu and select "Choose Program..." . From there select
"Python" if it appears, or click "Browse" and browse to "C:
\Python25\pytho n.exe", or the appropriate location if you have it
installed somewhere else.

Make sure to check the box next to "Always use the selected program to
open this kind of file."

Click "Ok".

Matt
Jul 8 '08 #9
And if you've gotten this far, why not take the next step:

http://aspn.activestate.com/ASPN/Coo.../Recipe/476204

and just type tryme (as opposed to tryme.py)

Gerry

Jul 9 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

50
5494
by: Edward K. Ream | last post by:
I would like to say a few (actually more than a few) words here about some recent discoveries I have made concerning the interaction of Leo and Python. If you don't want to hear an inventor enthuse about his work, please feel free not to read further :-) There are at least three, no four, no five, no six, no seven reasons why Leo and Python work so well together. Most are new (in my mind) with the 4.1 release of Leo. The first several...
8
1779
by: Xero Limit 126 | last post by:
Okay, I am completely new to Python, and I really dont understand much, but I was wondering how to make a python script/program into a standalone .EXE? I dont understand py2exe at all, so if someone could tell me or find me an easy (For a newbie) to convert Python scripts to EXEs, please let me know! Thanks for any help!
1
1406
by: Josiah Carlson | last post by:
QOTW: "Python, the language that wraps tightly around a problem and swallows it whole." -- Raymond Hettinger Because it is so important, this link is re-posted for the future (originally appeared in the December 15 Python-Url! posting by Cameron Laird): Martin Bless summarizes in an extremely valuable post what you need to know to generate Python-related executable binaries targeted for Windows*.
10
3689
by: Andrew Dalke | last post by:
Is there an author index for the new version of the Python cookbook? As a contributor I got my comp version delivered today and my ego wanted some gratification. I couldn't find my entries. Andrew dalke@dalkescientific.com
4
2473
by: presentt | last post by:
Hello, I'm running Ubuntu Linux 5.04. I just started teaching myself Python today, and have been reading a few things to get started. I came across something in one (namely http://docs.python.org/tut/node4.html#SECTION004220000000000000000) that confused me a little. It says:
8
4596
by: Joakim Persson | last post by:
Hello all. I am involved in a project where we have a desire to improve our software testing tools, and I'm in charge of looking for solutions regarding the logging of our software (originating from embedded devices). Currently, we are using a heavyweight, proprietary log tool developed by another part of the company. This tool contains all "standard" logging functionality, but we also need to insert "debug" log points in the software of...
34
3958
by: Ben Sizer | last post by:
I've installed several different versions of Python across several different versions of MS Windows, and not a single time was the Python directory or the Scripts subdirectory added to the PATH environment variable. Every time, I've had to go through and add this by hand, to have something resembling a usable Python installation. No such problems on Linux, whether it be Mandrake/Mandriva, Fedora Core, or Kubuntu. So why is the Windows...
20
18870
by: Ramdas | last post by:
How do I add users using Python scripts on a Linux machine? Someone has a script?
9
2767
by: matthias | last post by:
Howdy ! I started using the assert() stmt and found it quite useful :-) I have only one problem: I don't know how to turn them off again. I know that "-O" turns off assertions in general. However, how do I pass thus parameter to python to an executable script ?
0
8722
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9210
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9069
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8968
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8922
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6558
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5900
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4401
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2389
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.