py2exe question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • achrist@easystreet.com

    py2exe question

    The py2exe says that a console app should have the --console option
    and a windows app should have the --windows option.

    What is the way to py2exe a python program that uses both console and
    windows gui?

    TIA

    Al
  • Alex Martelli

    #2
    Re: py2exe question

    achrist@easystr eet.com wrote:
    [color=blue]
    > The py2exe says that a console app should have the --console option
    > and a windows app should have the --windows option.
    >
    > What is the way to py2exe a python program that uses both console and
    > windows gui?[/color]

    Haven't tried, but logically it should be a console -- this doesn't restrict
    what OTHER modules you can import, it just uses the equivalent of a .py
    script run with python.exe rather than a .pyw run with pythonw.exe, i.e. a
    "DOS box" console does appear when the program is run.


    Alex

    Comment

    • achrist@easystreet.com

      #3
      Re: py2exe question

      Alex Martelli wrote:[color=blue]
      >
      > achrist@easystr eet.com wrote:
      >[color=green]
      > > The py2exe says that a console app should have the --console option
      > > and a windows app should have the --windows option.
      > >
      > > What is the way to py2exe a python program that uses both console and
      > > windows gui?
      > > Haven't tried, but logically it should be a console -- this doesn't restrict[/color]
      > what OTHER modules you can import, it just uses the equivalent of a .py
      > script run with python.exe rather than a .pyw run with pythonw.exe, i.e. a
      > "DOS box" console does appear when the program is run.
      >[/color]

      Logically, you don't need these switches. Outside of py2exe a *.py
      gets a console and can open gui windows, a *.pyw is a pure gui
      program. Why the switches atall? IDK? Thought I'd ask.

      I'm having a little trouble getting a py2exe executable to run on
      a machine wo python installed. Just wondered if this has anything to
      do with it.


      Al

      Comment

      • Alex Martelli

        #4
        Re: py2exe question

        achrist@easystr eet.com wrote:
        [color=blue]
        > Alex Martelli wrote:[color=green]
        >>
        >> achrist@easystr eet.com wrote:
        >>[color=darkred]
        >> > The py2exe says that a console app should have the --console option
        >> > and a windows app should have the --windows option.
        >> >
        >> > What is the way to py2exe a python program that uses both console and
        >> > windows gui?
        >> > Haven't tried, but logically it should be a console -- this doesn't
        >> > restrict[/color]
        >> what OTHER modules you can import, it just uses the equivalent of a .py
        >> script run with python.exe rather than a .pyw run with pythonw.exe, i.e.
        >> a "DOS box" console does appear when the program is run.[/color]
        >
        > Logically, you don't need these switches. Outside of py2exe a *.py[/color]

        Logically, maybe not, but if you have chosen to run Windows instead,
        how do you avoid them? An EXE needs to let the OS know, via switches,
        if it wants a console or not -- that's all there is to it.
        [color=blue]
        > gets a console and can open gui windows, a *.pyw is a pure gui[/color]

        Not really: you can run either a .py or .pyw mainscript (and other
        extensions yet) with either pyhon.exe or pythonw.exe. Which EXE
        you choose to run as your interpreter is the one that either gets
        a console or doesn't -- because Windows associates a console (or
        lack thereof) with an EXE. By default most Python installers set
        registry associations of the two extensions .py and .pyw with the
        two interpreter executables in question -- that may be what's
        confusing you. But that's just a default that determines what
        the Windows GUI shell is going to do when you doubleclic a file
        with such an extension, etc -- you can still perfectly well run
        e.g. a .pyw mainscript with python.exe from a console (e.g. so you
        can see error messages, warnings etc in the console window).
        [color=blue]
        > program. Why the switches atall? IDK? Thought I'd ask.[/color]

        The switches let you control what goes on explicitly, just as
        you can control it explicitly by choosing one or the other of
        the two interpreters (python.exe or pythonw.exe) at a command
        prompt. I don't know what you mean by the 'idk' question.
        [color=blue]
        > I'm having a little trouble getting a py2exe executable to run on
        > a machine wo python installed. Just wondered if this has anything to
        > do with it.[/color]

        I don't see the connection.


        Alex

        Comment

        • achrist@easystreet.com

          #5
          Re: py2exe question

          The error I'm getting is in module imputil.pyo, line 601, in
          import_file, module does not define init function initpywintypes2 3.

          Please, can anyone tell what this means and how to fix?

          TIA


          Al

          Comment

          • Alex Martelli

            #6
            Re: py2exe question

            achrist@easystr eet.com wrote:
            [color=blue]
            > The error I'm getting is in module imputil.pyo, line 601, in
            > import_file, module does not define init function initpywintypes2 3.
            >
            > Please, can anyone tell what this means and how to fix?[/color]

            A C-coded Python extension module named XXX _must_ define (and
            export) a function named initXXX so that Python knows how to
            initialize it. This error message means that a module named
            pywintypes23.PY D (or .DLL) does exist, but fails to define and
            export the needed function. You might double-check about the
            module's existence - I can imagine anomalous cases where this
            message (somewhat misleadingly) might end up being given for
            modules that just don't exist, though I don't think py2exe could
            cause such anomalies (but it's a while since I studied it).

            If you _do_ find the pywintypes23.PY D you can check what it
            does define-and-export -- but you need some tools for that
            (I'm pretty sure there are downloadable ones though). But
            fixing it sounds harder...


            Alex

            Comment

            • Thomas Heller

              #7
              Re: py2exe question

              achrist@easystr eet.com writes:
              [color=blue]
              > The error I'm getting is in module imputil.pyo, line 601, in
              > import_file, module does not define init function initpywintypes2 3.
              >
              > Please, can anyone tell what this means and how to fix?[/color]

              I think it has to do with the way win32all finds and loads the
              PyWinTypes extension. Back in the past it was found via registry
              entries, nowadays Mark Hammond changed it to be done without the
              registry.

              py2exe up to version 0.4.2 has not be adapted to this change, but the
              0.5.0 alpha version (available in the files section of
              http://sf.net/projects/py2exe) is able to handle this.

              It requires Python 2.3 (because it uses the new zipimport feature), and
              a fairly new win32all.

              Thomas

              Comment

              • achrist@easystreet.com

                #8
                Re: py2exe question

                Thomas Heller wrote:[color=blue]
                >
                > py2exe up to version 0.4.2 has not be adapted to this change, but the
                > 0.5.0 alpha version (available in the files section of
                > http://sf.net/projects/py2exe) is able to handle this.
                >[/color]

                Looks like 0.5.0a is not picking up any of my command line arguments
                or producing any executable when I run it through the same batch
                file that worked for 0.4.2.

                Any docs on how to make if work?


                Al

                Comment

                • Chris Liechti

                  #9
                  Re: py2exe question

                  achrist@easystr eet.com wrote in news:3FA46952.6 0B2836D@easystr eet.com:
                  [color=blue]
                  > Thomas Heller wrote:[color=green]
                  >>
                  >> py2exe up to version 0.4.2 has not be adapted to this change, but the
                  >> 0.5.0 alpha version (available in the files section of
                  >> http://sf.net/projects/py2exe) is able to handle this.
                  >>[/color]
                  > Looks like 0.5.0a is not picking up any of my command line arguments
                  > or producing any executable when I run it through the same batch
                  > file that worked for 0.4.2.
                  >
                  > Any docs on how to make if work?[/color]

                  there is an example in the lib/site-packages/py2exe/samples dir
                  the syntax of the setup call is different

                  chris


                  --
                  Chris <cliechti@gmx.n et>

                  Comment

                  • achrist@easystreet.com

                    #10
                    Re: py2exe question

                    Chris Liechti wrote:[color=blue]
                    >
                    > achrist@easystr eet.com wrote in news:3FA46952.6 0B2836D@easystr eet.com:
                    >[color=green]
                    > > Looks like 0.5.0a is not picking up any of my command line arguments
                    > > or producing any executable when I run it through the same batch
                    > > file that worked for 0.4.2.
                    > >
                    > > Any docs on how to make if work?[/color]
                    >
                    > there is an example in the lib/site-packages/py2exe/samples dir
                    > the syntax of the setup call is different
                    >[/color]

                    I try to run the sample to see what comes out, and I get:

                    tlb = pythoncom.LoadR egTypeLib(typel ibCLSID, major, minor, lcid)
                    pywintypes.com_ error: (-2147319779, 'Library not registered.', None,
                    None)

                    I just installed win32all v161 last night.


                    Al

                    Comment

                    • Chris Liechti

                      #11
                      Re: py2exe question

                      achrist@easystr eet.com wrote in news:3FA540B2.5 453C98C@easystr eet.com:
                      [color=blue]
                      > Chris Liechti wrote:[color=green]
                      >>
                      >> achrist@easystr eet.com wrote in news:3FA46952.6 0B2836D@easystr eet.com:
                      >>[color=darkred]
                      >> > Looks like 0.5.0a is not picking up any of my command line arguments
                      >> > or producing any executable when I run it through the same batch
                      >> > file that worked for 0.4.2.
                      >> >
                      >> > Any docs on how to make if work?[/color]
                      >>
                      >> there is an example in the lib/site-packages/py2exe/samples dir
                      >> the syntax of the setup call is different
                      >>[/color]
                      >
                      > I try to run the sample to see what comes out, and I get:
                      >
                      > tlb = pythoncom.LoadR egTypeLib(typel ibCLSID, major, minor, lcid)
                      > pywintypes.com_ error: (-2147319779, 'Library not registered.', None,
                      > None)[/color]

                      just comment out the line with the "typelib" in it and do not build the COM
                      example. the com example seems torequire that makepy is run in advance, so
                      that the typlib is there.

                      the other examples worked fine for me.

                      chris

                      --
                      Chris <cliechti@gmx.n et>

                      Comment

                      Working...