473,804 Members | 5,054 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

os.system vs. Py2Exe

Lad
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
Jul 18 '05 #1
19 2223
Am Tue, 28 Sep 2004 03:00:23 -0700 schrieb Lad:
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


Hi,

What do you execute with os.system?

If the script you execute startswith
#!INTERPRETER
you might have trouble. I don't think this
is well supported under windows.

Try this: os.system("INTE RPRETER SCRIPT")
Regards,
Thomas

Jul 18 '05 #2
ex****@hope.cz (Lad) wrote in message news:<81******* *************** ***@posting.goo gle.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?
Jul 18 '05 #3
Lad
gj*****@usa.com (Greg) wrote in message news:<77******* *************** ****@posting.go ogle.com>...
ex****@hope.cz (Lad) wrote in message news:<81******* *************** ***@posting.goo gle.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('Myfi le.txt')

When I use os.startfile instead of os.system it works well.
Jul 18 '05 #4
On 2004-09-28, Lad <ex****@hope.cz > wrote:
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('Myfi le.txt')
What makes you think that should work?

Is Myfile.txt an executable file? Under Win32, don't
executble file's names usually end in .exe?
When I use os.startfile instead of os.system it works well.


Then why not use os.startfile()? It's the correct way to start
the program that is supposed to handle .txt files.

--
Grant Edwards grante Yow! Are we live or
at on tape?
visi.com
Jul 18 '05 #5
Lad wrote:
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,


What operating system is the other computer running?
Jul 18 '05 #6
Lad wrote:
gj*****@usa.co m (Greg) wrote in message news:<77******* *************** ****@posting.go ogle.com>...

ex****@hope.c z (Lad) wrote in message news:<81******* *************** ***@posting.goo gle.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('Myfi le.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

Jul 18 '05 #7
Jeff Shannon wrote:
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.)


Unfortunately for your theory, on XP typing just the name of the
file (at least with a .txt file) does indeed open it in the associated
application.

I suspect the "other" machine he is using is not an XP machine, and
thus not suffering from such unexpected behaviour. Thanks, Mickysoft...

-Peter
Jul 18 '05 #8
Peter Hansen wrote:
Jeff Shannon wrote:
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.)

Unfortunately for your theory, on XP typing just the name of the
file (at least with a .txt file) does indeed open it in the associated
application.

Why, so it does... and under Win2K, as well.
I suspect the "other" machine he is using is not an XP machine, and
thus not suffering from such unexpected behaviour. Thanks, Mickysoft...

Yes, if the "other" machine is Win9x/ME (or, I believe, NT4), using the
..txt filename as a command will result in an error. As it should, also,
under *nix (and probably MacOS) as well, unless I'm even more confused
than I'd thought. ;)

This does, at least, do away with the need to presume some sort of
screwy settings on the O.P.'s machine -- said screwy settings being
provided by default from Microsoft. ;)

Jeff Shannon
Technician/Programmer
Credit International

Jul 18 '05 #9
On 28 Sep 2004 19:15:52 GMT, Grant Edwards <gr****@visi.co m> wrote:
On 2004-09-28, Lad <ex****@hope.cz > wrote:
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('Myfi le.txt')


What makes you think that should work?

Is Myfile.txt an executable file? Under Win32, don't
executble file's names usually end in .exe?


It's not a matter of _being_ executable, it's a matter of having an executable
_associated with_ the extension. Typically notepad.exe is associated with .txt
(via an intermediate association with a generic file type name that in turn
is associated with the actual executable):
----
[16:30] C:\pywk\junk>as soc .txt
..txt=txtfile

[16:30] C:\pywk\junk>ft ype txtfile
txtfile=C:\WINN T\System32\NOTE PAD.EXE %1
----
When I use os.startfile instead of os.system it works well.


Then why not use os.startfile()? It's the correct way to start
the program that is supposed to handle .txt files.

One difference is that os.system will wait for the completion of what it starts,
but os.startfile will start a new process to do it, and return immediately.

I would try it with full absolute paths to everything the in the os.system call.
If that works, you can look for why the environment is different.

BTW, if you execute via start menu or double clicking a desktop icon, the associated
..lnk may specify the starting directory. If that is different from current directory,
bare names may be looked for in unexpected place and not be found (or worse, a file
of the same name may be found, but be the wrong one). Right click on the icon and look
at the properties. Or right click the task bar and chase properties of start menus that way,
or start>settings> taskbar> etc.

BTW2, if you want to type in a file name without extension, as you can with .exe
and .bat etc., it implies a priority choice if e.g. both .exe and .bat exist
in the same path directory. You can influence this by the PATHEXT environment
variable. Go to a console window and type
help ftype|more
and also
help assoc|more
for additional info

BTW3, beware of changing .exe association!! I was aghast to find (some time ago) that
NS4.5 let me change that association via its file association option interface.
It was pretty squirrely to get back to normal. No console commands would work.
(IIRC I finally used start menu>run>browse to find and execute regedit32 and repaired
it that way, after booting in last known good to see what the registry was supposed to be
for .exe). Very anxious moments there ;-)

Regards,
Bengt Richter
Jul 18 '05 #10

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

Similar topics

6
4056
by: bap | last post by:
When I try to run a program on a clean machine using the VPython extensions after compiling with PY2EXE I get the following error message: "The procedure entry point IsWow64Process could not be located in the dynamic link library KERNEL32.dll" . The compiled version runs fine on the original machine (win NT OS) but gives this error message on a machine without VPython installed (Win 2K OS). Is this anything that can be fixed with...
0
2589
by: David Vaughan | last post by:
py2exe and Pmw problem ---------------------- I was really surprised not to find some faq setting out what to do to get py2exe working for a program using Pmw. I'm haemorrhaging time here, and I'm now just after step-by-step guidance on using py2exe and Pmw together. I wasn't expecting this to take hours... I've used py2exe succesfully on non-gui programs, and the Python program
0
1534
by: Jimmy Retzlaff | last post by:
py2exe 0.6.4 released ===================== py2exe is a Python distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation. Console and Windows (GUI) applications, Windows NT services, exe and dll COM servers are supported. Changes in 0.6.4:
0
1522
by: Jimmy Retzlaff | last post by:
py2exe 0.6.5 released ===================== py2exe is a Python distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation. Console and Windows (GUI) applications, Windows NT services, exe and dll COM servers are supported. Changes in 0.6.5:
2
4149
by: Maria.Reinhammar | last post by:
I have an app using active_directory.py and the std module asyncore in a Windows Service. Works perfectly! That is, until I try to use py2exe to create a standalone (need to avoid installing the entire Python etc. on the target system). When I try to start the installed Service, the system tells me it terminates prematurely and in the event log I find: The instance's SvcRun() method failed
0
1732
by: Jimmy Retzlaff | last post by:
py2exe 0.6.6 released ===================== py2exe is a Python distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation. Console and Windows (GUI) applications, Windows NT services, exe and dll COM servers are supported. Changes in 0.6.6:
5
6547
by: Michael | last post by:
I'm trying to build a exe on a vista system using py2exe. It will deploy to vista and XP systems. If it matters, the application uses pyserial, as well. I have VS Studio 2005 installed on this laptop as well. I've found this so far that seems to be identical to what I'm seeing (for non-python programs): http://www.thescripts.com/forum/thread611031.html When I attempt to run, I get "The procedure entry point _except_handler4_common could...
1
2992
by: Jimmy Retzlaff | last post by:
py2exe 0.6.8 released ===================== py2exe is a Python distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation. Console and Windows (GUI) applications, Windows NT services, exe and dll COM servers are supported. Changes in 0.6.8:
0
1533
by: Larry Bates | last post by:
Jimmy Retzlaff wrote: Everyone, Thanks for all your hard work on py2exe, it is greatly appreciated. -Larry Bates
0
3124
by: Jimmy Retzlaff | last post by:
py2exe 0.6.9 released ===================== py2exe is a Python distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation. Console and Windows (GUI) applications, Windows NT services, exe and dll COM servers are supported. Changes in 0.6.9:
0
9706
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
10332
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
10320
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
10077
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
7620
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
6853
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
5521
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
3820
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2991
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.