os.system vs. Py2Exe
Jeff Shannon
jeff at ccvcorp.com
Tue Sep 28 16:26:19 EDT 2004
Lad wrote:
>gjbaker at usa.com (Greg) wrote in message news:<77ce170c.0409280647.7e98e76d at posting.google.com>...
>
>
>>export at hope.cz (Lad) wrote in message news:<81a41dd.0409280200.1a74edd1 at posting.google.com>...
>>
>>
>>>I used Py2exe to compile my script( I use XP).
>>>The compiled script works OK on my XP where Python is installed.
>>>But when I install the compiled exe to another computer,
>>>
>>>os.system
>>>
>>>causes the following error:
>>>Bad file or command name
>>>
>>>Any help would be appreciated.
>>>Lad
>>>
>>>
>>Did you install the python dll as well?
>>
>>
>
>Yes, I installed all files( I think) because everything else works.
> Only os.system does NOT.
>I use os.system to open txt file.I use it like os.system('Myfile.txt')
>
>When I use os.startfile instead of os.system it works well.
>
>
I suspect that the situation here is that you've got some unusual WinXP
setting that's telling it that .txt files are executable in some way.
If os.system('file.txt') works on your system, then it's your system
that's the odd one; Python (and the other computer) are behaving as
expected. (It's possible, in Win2K/WinXP, to register particular
extensions as 'executable' through a specific other program; this is how
.py scripts are handled, so typing 'script.py' is equivalent to typing
'python script.py'.)
Remember, os.system() is roughly equivalent to typing the argument at a
command line. Does typing "myfile.txt" at a commandline prompt open
that file in a text editor? (Hint -- it shouldn't, under normal
circumstances.)
In this case, I'm pretty sure that using os.startfile() is the
appropriate way of doing what you want.
Jeff Shannon
Technician/Programmer
Credit International
More information about the Python-list
mailing list