Problems running a compiled script on Windows.

Wayne piercew at hushmail.com
Mon Aug 13 11:07:18 EDT 2001


Peter Hansen <peter at engcorp.com> wrote in message news:<3B771FBA.B73C3F07 at engcorp.com>...
> Wayne wrote:
> > 
> > I just finished a program/script and compiled it (can't have an
> > interpreter on the dest. machine).  When I run the .py from the
> > command line it works fine, however, when I run the .exe from the
> > command line it doesn't work.  It also doesn't work when I run it from
> > Explorer.
> 
> Always describe *how* something doesn't work.  What are the
> symptoms?  Does the computer crash?  Does nothing appear to 
> happen?  Does everything work *except* some minor part of 
> the logic?  It could be any of these or a zillion other things.
> (Describing what "works fine" means in the case of your
> program might be of some help, too.)

Sorry, I didn't realize how vague that post was when writing it. :-/ 
Thank you for your patience.

> Also, there is no standard Python way to create .exe files 
> on Windows.  Which method did you use?

I figured out what the problem here was. When Standalone.py created
the .exe it excluded the 'posixpath' module automatically. My script
needed that, which is why it worked when running interactively but not
when compiled.

> You imply that even the .py doesn't work from Explorer.  Maybe
> the issue has nothing to do with the .exe, and everything to
> do with a problem related to the reason it won't run in 
> Explorer.  Are you perhaps looking at two different problems?
> (If you run a .py from Explorer, it just opens a console 
> anyway.  Were you running it as a .pyw, or invoking pythonw
> directly, or was this whole assumption wrong?)

I think the other problem with the script running from the command
line and not explorer was relating to the "__name__='__main__':" code.
 When I removed that it works fine; I just call the class at the end
of the script.

> > I'm using Active Python 2.1.1 with Qt on Win2K.  I've tried to find
> > all the instances of stdout and stderr that might require console.
> 
> Neither stdout nor stderr *require* the console.  That is, the program 
> will run fine without a console, other than that any output sent to
> those files will not appear anywhere, which could obviously
> prevent some programs from appearing to work.  Is your program 
> failing in some other way, and you are assuming it is because
> you have prints which can't "go" anywhere?  I'm not sure
> there is enough information in your post to point out an obvious
> place to look for a fix... (of course, that has rarely stopped
> some people in this group from providing useful and correct 
> answers, but it might help a little :-)

Ok, thanks.  I've been trying to figure out how to 'hide' the output
from the BaseHTTPServer...unfortunately there is no /dev/null on NT.

One item that is still confusing me is using Standalone.py with Qt.  I
designed the form in BlackAdder and compiled to an exe.  When the
program is run from a DOS prompt it returns to another prompt, the
same for explorer.

When I run the program with either python or pythonw against the
uncompiled script it works fine and shows the dialog.  The reason this
is a little confusing is that I've written other BA programs and
compiled them with Standalone.py without making any modifications.

When I run the program from the "dist" directory I get the following
error:

Traceback (most recent call last):
  File "<string>", line 1, in ?
  File "E:\installer_4a2\support\imputil.py", line 98, in _import_hook
    top_module = self._import_top_module(parts[0])
  File "E:\installer_4a2\support\imputil.py", line 184, in
_import_top_module
    module = item.import_top(name)
  File "E:\installer_4a2\support\imputil.py", line 211, in import_top
    return self._import_one(None, name, name)
  File "E:\installer_4a2\support\imputil.py", line 266, in _import_one
    module = self._process_result(result, fqname)
  File "E:\installer_4a2\support\imputil.py", line 295, in
_process_result
    exec code in module.__dict__
  File "mgt.py", line 9, in ?
  File "E:\installer_4a2\support\imputil.py", line 101, in
_import_hook
    raise ImportError, 'No module named ' + fqname
ImportError: No module named qt

If I try to for the inclusion of qt by adding an "includes=qt" line to
the .cfg file for Builder I get an error "qt not found".  If I run the
interactive interpreter and "import qt" it will find the module
though.

:-/  I'm sure it's a typo on my part though....thanks again for your
help.

Wyane



More information about the Python-list mailing list