Re: Windows and python execution
* Mark Carter (2005-12-26 23:06 +0100) I had installed python 2.4 in the standard way, so py files were already associated with python when you double-clicked them from Explorer. Using my set meant that if I wanted to use py files from the command line, I could just type out the script name (you have to be in the right directory, of course), and it works. Here's a snippit from my autoexec.bat files: set PATH=C:\python24;%PATH% set .py=c:\python24\python.exe If you installed Python the normal way, .py files are already associated with Python. Windows uses the registry and doesn't make any difference whether you doubleclick a file or type the name on the command line -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows and python execution
Thorsten Kampe wrote: If you installed Python the normal way, .py files are already associated with Python. Windows uses the registry and doesn't make any difference whether you doubleclick a file or type the name on the command line The difference is whether you can execute the script by typing scriptname.py or merely scriptname. With the set .py approach Mark was mentioning, even though it's not supported by vanilla Windows, you can do the latter. Same with setting the PATHEXT environment variable, which the ActivePython distribution apparently does. The normal way of installing Python does *not* set enable this, requiring you to execute scripts with the full scriptname.py. -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows and python execution
Some of the confusion probably comes from which installation people use. I used the latest ActiveState distribution of Python. As one of the other posters observed it automatically adds the .py extension in the PATHEXT system variable. At least I didn't put it there. Then, as we've discussed, as long as the directory containing your scripts is in the path, you can type nothing by myscript.py at the command line and your script will execute from any location on the machine. rpd Peter Hansen wrote: Peter Hansen wrote: BartlebyScrivener wrote: What you need to do is include the following line in autoexec.bat: set .py=c:\python24\python.exe Whatever works for you. I don't have that command in my autoexec.bat file and my python scripts execute from any location because the directory they are stored in is in my PATH variable. ... Merely adding the folder containing the EXE to PATH does *not* let you avoid typing python before the script name, as your posts imply. D'oh... okay, people (including me) are reading others' posts with preconceptions about what they are talking about in mind. The PATHEXT thing is required to be able to type just scriptname _without_ the .py extension. Alternatively, it appears there's yet another obscurely documented feature involving setting environment variables that resemble file extensions, as posted by others. (Where do these things come from? It's like Microsoft releases the OS, then periodically sends private emails to random people, pointing out obscure new features, so that they can tell others in some feeble effort to make using Windows look like a grassroots effort or something. How are regular mortals supposed to find out about things like set .py=?) The ability to run the script with just scriptname.py comes from, I believe, having a file association set up with ftype and assoc or the equivalent registry entries. For this to work from _any_ location one must have the folder containing the *script* in the PATH, as with any executable, while the path specified by FTYPE points to the Python executable. (This ftype/assoc file association is set up by the standard installer, which is why it works for BartlebyScrivener). -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows and python execution
The PATHEXT allows you to execute the script without typing the .py extension. Roger BartlebyScrivener [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Some of the confusion probably comes from which installation people use. I used the latest ActiveState distribution of Python. As one of the other posters observed it automatically adds the .py extension in the PATHEXT system variable. At least I didn't put it there. Then, as we've discussed, as long as the directory containing your scripts is in the path, you can type nothing by myscript.py at the command line and your script will execute from any location on the machine. rpd Peter Hansen wrote: Peter Hansen wrote: BartlebyScrivener wrote: What you need to do is include the following line in autoexec.bat: set .py=c:\python24\python.exe Whatever works for you. I don't have that command in my autoexec.bat file and my python scripts execute from any location because the directory they are stored in is in my PATH variable. ... Merely adding the folder containing the EXE to PATH does *not* let you avoid typing python before the script name, as your posts imply. D'oh... okay, people (including me) are reading others' posts with preconceptions about what they are talking about in mind. The PATHEXT thing is required to be able to type just scriptname _without_ the .py extension. Alternatively, it appears there's yet another obscurely documented feature involving setting environment variables that resemble file extensions, as posted by others. (Where do these things come from? It's like Microsoft releases the OS, then periodically sends private emails to random people, pointing out obscure new features, so that they can tell others in some feeble effort to make using Windows look like a grassroots effort or something. How are regular mortals supposed to find out about things like set .py=?) The ability to run the script with just scriptname.py comes from, I believe, having a file association set up with ftype and assoc or the equivalent registry entries. For this to work from _any_ location one must have the folder containing the *script* in the PATH, as with any executable, while the path specified by FTYPE points to the Python executable. (This ftype/assoc file association is set up by the standard installer, which is why it works for BartlebyScrivener). -Peter == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 100,000 Newsgroups ---= East/West-Coast Server Farms - Total Privacy via Encryption =--- -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows and python execution
BartlebyScrivener wrote: What you need to do is include the following line in autoexec.bat: set .py=c:\python24\python.exe Whatever works for you. I don't have that command in my autoexec.bat file and my python scripts execute from any location because the directory they are stored in is in my PATH variable. But only because you type python scriptname.py instead of just scriptname.py, right? Or because something or someone (I don't believe the standard distribution does this) changed the PATHEXT environment variable to contain .PY somewhere. Merely adding the folder containing the EXE to PATH does *not* let you avoid typing python before the script name, as your posts imply. -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows and python execution
Peter Hansen wrote: BartlebyScrivener wrote: What you need to do is include the following line in autoexec.bat: set .py=c:\python24\python.exe Whatever works for you. I don't have that command in my autoexec.bat file and my python scripts execute from any location because the directory they are stored in is in my PATH variable. ... Merely adding the folder containing the EXE to PATH does *not* let you avoid typing python before the script name, as your posts imply. D'oh... okay, people (including me) are reading others' posts with preconceptions about what they are talking about in mind. The PATHEXT thing is required to be able to type just scriptname _without_ the .py extension. Alternatively, it appears there's yet another obscurely documented feature involving setting environment variables that resemble file extensions, as posted by others. (Where do these things come from? It's like Microsoft releases the OS, then periodically sends private emails to random people, pointing out obscure new features, so that they can tell others in some feeble effort to make using Windows look like a grassroots effort or something. How are regular mortals supposed to find out about things like set .py=?) The ability to run the script with just scriptname.py comes from, I believe, having a file association set up with ftype and assoc or the equivalent registry entries. For this to work from _any_ location one must have the folder containing the *script* in the PATH, as with any executable, while the path specified by FTYPE points to the Python executable. (This ftype/assoc file association is set up by the standard installer, which is why it works for BartlebyScrivener). -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows and python execution
Tim Roberts wrote: Mark Carter [EMAIL PROTECTED] wrote: What you need to do is include the following line in autoexec.bat: set .py=c:\python24\python.exe This will achieve the desired result. I'm suprised more people don't use it. They don't use it, because it doesn't do anything. I'd be interested to know where you read that. This is a feature of 4NT, a commercial replacement for cmd.exe. And unlike cmd.exe, it even allows redirection of stdin/stdout when a script is executed through the extension (the OP's next post is probably going to be 'why doesn't redirection work?'). Daniel -- http://mail.python.org/mailman/listinfo/python-list
Windows and python execution
What I would like to do it type something like myscript.py instead of python myscript.py on a Windows console. I know its possible because Ruby scripts manage to do this - I just don't know the registry settings that need to be tweaked to enable it. Any ideas (I'd prefer to know the registry settings rather than a graphical way to accomplish the goal)? -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows and python execution
Well, can't help with the registry, but I suppose you could search google for edit system variables path registry and find the hard way. The easy way is: You need to add the path of the directory where you keep myscript.py to your system path. You do this by going to Control Panel | System | Advanced | Environmental Variables. At the bottom under System Variables, edit the variable PATH and add the directory where you want to keep your Python scripts. rpd -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows and python execution
On 26/12/05, Mark Carter [EMAIL PROTECTED] wrote: What I would like to do it type something like myscript.pyinstead of python myscript.py Open an explorer window or open My Computer Click on TOOLS then FOLDER OPTIONS Select the FILE TYPES tab and click on NEW Enter PY as the file extension and click OK Select PY from the list and click CHANGE Select your Python.exe executable from the list or (using other) from your Python folder in your Python folder (c:\python24?) create a file called python.pth and add a line for any *subdir* that you have stored your python apps and scripts in eg: c:\pythonapps c:\pythonapps\data c:\pythontest c:\pythontest\archives c:\pythontest\archives\temp HTH :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows and python execution
Mark Carter [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: What I would like to do it type something like myscript.py instead of python myscript.py on a Windows console. I know its possible because Ruby scripts manage to do this - I just don't know the registry settings that need to be tweaked to enable it. Any ideas (I'd prefer to know the registry settings rather than a graphical way to accomplish the goal)? As another poster points out, be sure that your Python is on your path. And there is a PATHEXT environment variable, which contains extensions that signal that the program is executable. Add .PY and .PYW to this list and you will be good to go. -- rzed -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows and python execution
rzed wrote: Mark Carter [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: What I would like to do it type something like myscript.py instead of python myscript.py As another poster points out, be sure that your Python is on your path. And there is a PATHEXT environment variable, Aha. You'bve provided a significant clue. What you need to do is include the following line in autoexec.bat: set .py=c:\python24\python.exe This will achieve the desired result. I'm suprised more people don't use it. -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows and python execution
What you need to do is include the following line in autoexec.bat: set .py=c:\python24\python.exe Whatever works for you. I don't have that command in my autoexec.bat file and my python scripts execute from any location because the directory they are stored in is in my PATH variable. -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows and python execution
Mark Carter wrote: rzed wrote: Mark Carter [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: What I would like to do it type something like myscript.py instead of python myscript.py As another poster points out, be sure that your Python is on your path. And there is a PATHEXT environment variable, Aha. You'bve provided a significant clue. What you need to do is include the following line in autoexec.bat: set .py=c:\python24\python.exe This will achieve the desired result. I'm suprised more people don't use it. I'm surprised the installer doesn't do it :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows and python execution
The installer can put python.exe in his PATH but if he's storing his scripts in some oddball place then he has to tell Windows where to find them. rpd -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows and python execution
BartlebyScrivener wrote: The installer can put python.exe in his PATH but if he's storing his scripts in some oddball place then he has to tell Windows where to find them. I think you're misunderstanding what I was after. python.exe is already in my PATH. What I was trying to do was execute a python script without having to type the word python explicitly. For that, you need the set command that I listed in a previous post. Anyway, I want to be able to put my scripts in oddball places, as they form part of separate projects rather than a generally-runnable script. It doesn't matter to me that Windows cannot find the script itself - because I just go to the directory where's it's at. The upshot is that my original problem has now been solved, and that discussing the matter further will only likely confuse the issue. -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows and python execution
What I was trying to do was execute a python script without having to type the word python explicitly. For that, you need the set command that I listed in a previous post. I'm not confused and I like to keep my scripts in oddball places too. Namely d:\python. All I'm saying is I don't use the set command. I don't have an autoexec.bat file. I simply place d:\python in the path variable and I can execute python scripts from the command line from any directory without typing python first. I just type myscript.py and it executes. Okay. You're welcome. rpd -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows and python execution
On Mon, 26 Dec 2005 14:53:28 +, Mark Carter [EMAIL PROTECTED] wrote: rzed wrote: Mark Carter [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: What I would like to do it type something like myscript.py instead of python myscript.py As another poster points out, be sure that your Python is on your path. And there is a PATHEXT environment variable, Aha. You'bve provided a significant clue. What you need to do is include the following line in autoexec.bat: set .py=c:\python24\python.exe This will achieve the desired result. I'm suprised more people don't use it. I wasn't aware of that syntax for set. What OS/platform/shell is that from? How did you go from the PATHEXT clue to the set command you specify and decide not to set pathext, e.g., by something like set PATHEXT=%PATHEXT%;.py Does your set do the pathext and assoc and ftype all in one swell foop? Regards, Bengt Richter -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows and python execution
Bengt Richter wrote: And there is a PATHEXT environment variable, Aha. You'bve provided a significant clue. What you need to do is include the following line in autoexec.bat: set .py=c:\python24\python.exe This will achieve the desired result. I'm suprised more people don't use it. I wasn't aware of that syntax for set. What OS/platform/shell is that from? Windows XP, bog-standard default shell. UNIXers have it easy because they can use the normal shebang. How did you go from the PATHEXT clue to the set command you specify I can't remember. It was a bit of luck, I think. I happened upon: http://www.jpsoft.com/help/index.htm?exeext.htm probably as a result of Googling for PATHEXT. and decide not to set pathext, e.g., by something like set PATHEXT=%PATHEXT%;.py Does your set do the pathext and assoc and ftype all in one swell foop? Actually, I haven't figured out what PATHEXT is actually supposed to do. It seemed to me that Windows couldn't possibly know that a py file should be started by python.exe, whereas my set .py= ... would. I had installed python 2.4 in the standard way, so py files were already associated with python when you double-clicked them from Explorer. Using my set meant that if I wanted to use py files from the command line, I could just type out the script name (you have to be in the right directory, of course), and it works. Here's a snippit from my autoexec.bat files: set PATH=C:\python24;%PATH% set .py=c:\python24\python.exe -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows and python execution
Mark Carter [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: Bengt Richter wrote: And there is a PATHEXT environment variable, Aha. You'bve provided a significant clue. What you need to do is include the following line in autoexec.bat: set .py=c:\python24\python.exe This will achieve the desired result. I'm suprised more people don't use it. I wasn't aware of that syntax for set. What OS/platform/shell is that from? Windows XP, bog-standard default shell. UNIXers have it easy because they can use the normal shebang. How did you go from the PATHEXT clue to the set command you specify I can't remember. It was a bit of luck, I think. I happened upon: http://www.jpsoft.com/help/index.htm?exeext.htm probably as a result of Googling for PATHEXT. and decide not to set pathext, e.g., by something like set PATHEXT=%PATHEXT%;.py Does your set do the pathext and assoc and ftype all in one swell foop? Actually, I haven't figured out what PATHEXT is actually supposed to do. It seemed to me that Windows couldn't possibly know that a py file should be started by python.exe, whereas my set .py= ... would. I had installed python 2.4 in the standard way, so py files were already associated with python when you double-clicked them from Explorer. Using my set meant that if I wanted to use py files from the command line, I could just type out the script name (you have to be in the right directory, of course), and it works. Here's a snippit from my autoexec.bat files: set PATH=C:\python24;%PATH% set .py=c:\python24\python.exe I should have asked which Windows version you had. My bad. On Win2k or XP, adding .py (for instance) to the PATHEXT variable means that you can execute myNeatProgram.py with this command-line: promptmyNeatProgram Since .py appears in the PATHEXT variable, the system knows that .py files are executable, so it's not necessary even to specify them. What must happen, I suppose, is that the system looks for myNeatProgram.bat, myNeatProgram.com, myNeatProgram.exe, etc., until it hits upon myNeatProgram.py and proceeds to run it. So if you have a myNeatProgram.bat that appears earlier in your path than myNeatProgram.py does, the bat file is what gets run. -- rzed -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows and python execution
rzed wrote: I should have asked which Windows version you had. XP Pro My bad. On Win2k or XP, adding .py (for instance) to the PATHEXT variable means that you can execute myNeatProgram.py with this command-line: promptmyNeatProgram Oh, now I see! It's beginning to make sense to me. I'll have to try that out. Thanks for the tip. -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows and python execution
Mark Carter [EMAIL PROTECTED] wrote: rzed wrote: Mark Carter [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: What I would like to do it type something like myscript.py instead of python myscript.py As another poster points out, be sure that your Python is on your path. And there is a PATHEXT environment variable, Aha. You'bve provided a significant clue. What you need to do is include the following line in autoexec.bat: set .py=c:\python24\python.exe This will achieve the desired result. I'm suprised more people don't use it. They don't use it, because it doesn't do anything. I'd be interested to know where you read that. What the OP needs is this: assoc .py=Python.File ftype Python.File=c:\Apps\Python24\python.exe %1 %* assoc .pyw=Python.NoConFile ftype Python.NoConFile=c:\Apps\Python24\pythonw.exe %1 %* Substitute your own Python path. The Python .msi installer DOES do this, if you let it do its default thing. You should check whether these are already set up, by doing this: assoc .py -- - Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list