Python scripts in IIS

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jon Cosby

    Python scripts in IIS

    I'm having trouble executing Python scripts in IIS. I have the error message
    "%1 is not a valid Win32 application". Anyone know what this is about?

    Jon Cosby


  • Peter Hansen

    #2
    Re: Python scripts in IIS

    Jon Cosby wrote:[color=blue]
    >
    > I'm having trouble executing Python scripts in IIS. I have the error message
    > "%1 is not a valid Win32 application". Anyone know what this is about?[/color]

    Somewhere, something is attempting to execute an application with an
    argument that contains "%1", which is normally substituted with a
    variable string supplied by something else. Clearly that isn't happening
    here.

    Without more detail, I doubt anyone can help much more. Maybe you should
    post some snippets of code. Also, if the error message actually includes
    more information (e.g. such as a Python traceback would have), cut and paste
    the entire output rather than just retyping a part of it (if that's what you
    did).

    -Peter

    Comment

    • Jon Cosby

      #3
      Re: Python scripts in IIS

      "Peter Hansen" <peter@engcorp. com> wrote
      [color=blue][color=green]
      > > I'm having trouble executing Python scripts in IIS. I have the error[/color][/color]
      message[color=blue][color=green]
      > > "%1 is not a valid Win32 application". Anyone know what this is about?[/color]
      >
      > Somewhere, something is attempting to execute an application with an
      > argument that contains "%1", which is normally substituted with a
      > variable string supplied by something else. Clearly that isn't happening
      > here.
      >
      > Without more detail, I doubt anyone can help much more. Maybe you should
      > post some snippets of code. Also, if the error message actually includes
      > more information (e.g. such as a Python traceback would have), cut and[/color]
      paste[color=blue]
      > the entire output rather than just retyping a part of it (if that's what[/color]
      you[color=blue]
      > did).
      >
      > -Peter[/color]

      I get the same line with all of my scripts, nothing else.

      Jon


      Comment

      • Peter Hansen

        #4
        Re: Python scripts in IIS

        Jon Cosby wrote:[color=blue]
        >
        > "Peter Hansen" <peter@engcorp. com> wrote[color=green]
        > > Without more detail, I doubt anyone can help much more.[/color]
        >
        > I get the same line with all of my scripts, nothing else.[/color]

        Please go back and reread the previous sentence again. If you won't
        provide some context, you won't likely get helpful answers.

        I'll try again: *what* is giving you that error message? Some program
        prints it, somewhere. Is it in a log file? Printed to the console?
        In a popup dialog box? On the browser screen? What exact command did you
        type just before you saw that error. Have you installed Python?
        What version? etc etc etc...

        -Peter

        Comment

        • Jon Cosby

          #5
          Re: Python scripts in IIS

          "Peter Hansen" <peter@engcorp. com> wrote
          [color=blue]
          > Jon Cosby wrote:[color=green]
          > >
          > > "Peter Hansen" <peter@engcorp. com> wrote[color=darkred]
          > > > Without more detail, I doubt anyone can help much more.[/color]
          > >
          > > I get the same line with all of my scripts, nothing else.[/color]
          >
          > Please go back and reread the previous sentence again. If you won't
          > provide some context, you won't likely get helpful answers.
          >
          > I'll try again: *what* is giving you that error message? Some program
          > prints it, somewhere. Is it in a log file? Printed to the console?
          > In a popup dialog box? On the browser screen? What exact command did you
          > type just before you saw that error. Have you installed Python?
          > What version? etc etc etc...
          >[/color]

          Sorry. It's in the browser window. The script does not execute. I have "Show
          friendly http error messages" set to false in Internet Explorer. As it
          happens on all of the scripts, I can't single out one command. I have
          ActiveState's build of Python 2.3, and don't recall running into this
          previously, but there might be something in the IIS configuration I'm
          overlooking.

          Jon


          Comment

          • Scott F

            #6
            Re: Python scripts in IIS

            "Jon Cosby" <jcosby@nospam. net> wrote in
            news:aHv_b.6560 $aT1.3079@newsr ead1.news.pas.e arthlink.net:
            [color=blue]
            >
            > Sorry. It's in the browser window. The script does not execute. I
            > have "Show friendly http error messages" set to false in Internet
            > Explorer. As it happens on all of the scripts, I can't single out
            > one command. I have ActiveState's build of Python 2.3, and don't
            > recall running into this previously, but there might be something
            > in the IIS configuration I'm overlooking.[/color]

            Go to the Properties of the (Default) Web site, Home Directory tab,
            Configuration button. On the Mappings tab, add a mapping for Python in
            the form

            <pathtopython>\ python.exe %s %s

            Use your actual pathtopython and don't substitute anything for %s %s.

            Should work fine.

            Scott

            Comment

            • Jon Cosby

              #7
              Re: Python scripts in IIS


              "Scott F" <sdfATexpertune DOTcom> wrote[color=blue]
              >[color=green]
              > >
              > > Sorry. It's in the browser window. The script does not execute. I
              > > have "Show friendly http error messages" set to false in Internet
              > > Explorer. As it happens on all of the scripts, I can't single out
              > > one command. I have ActiveState's build of Python 2.3, and don't
              > > recall running into this previously, but there might be something
              > > in the IIS configuration I'm overlooking.[/color]
              >
              > Go to the Properties of the (Default) Web site, Home Directory tab,
              > Configuration button. On the Mappings tab, add a mapping for Python in
              > the form
              >
              > <pathtopython>\ python.exe %s %s
              >
              > Use your actual pathtopython and don't substitute anything for %s %s.
              >
              > Should work fine.
              >[/color]
              Thanks. I had left out the trailing arguments. What is "%s" for, anyway?

              Jon


              Comment

              • Scott F

                #8
                Re: Python scripts in IIS

                "Jon Cosby" <jcosby@nospam. net> wrote in
                news:6DJ_b.7904 $aT1.2403@newsr ead1.news.pas.e arthlink.net:
                [color=blue]
                > Thanks. I had left out the trailing arguments. What is "%s" for,
                > anyway?[/color]

                I don't know. With MS I usually don't bother finding out if I can get
                things to work.

                Scott

                Comment

                • Gandalf

                  #9
                  Re: Python scripts in IIS


                  Jon Cosby wrote:
                  [color=blue]
                  >"Scott F" <sdfATexpertune DOTcom> wrote
                  >
                  >[color=green][color=darkred]
                  >>>Sorry. It's in the browser window. The script does not execute. I
                  >>>have "Show friendly http error messages" set to false in Internet
                  >>>Explorer. As it happens on all of the scripts, I can't single out
                  >>>one command. I have ActiveState's build of Python 2.3, and don't
                  >>>recall running into this previously, but there might be something
                  >>>in the IIS configuration I'm overlooking.
                  >>>
                  >>>[/color]
                  >>Go to the Properties of the (Default) Web site, Home Directory tab,
                  >>Configurati on button. On the Mappings tab, add a mapping for Python in
                  >>the form
                  >>
                  >><pathtopython >\python.exe %s %s
                  >>
                  >>Use your actual pathtopython and don't substitute anything for %s %s.
                  >>
                  >>Should work fine.
                  >>
                  >>
                  >>[/color]
                  >Thanks. I had left out the trailing arguments. What is "%s" for, anyway?
                  >
                  >Jon
                  >
                  >[/color]
                  Sorry, I just read this message. I did not the beginning of this thread.
                  Jon, why don't you register
                  Python as an ActiveX scripting language? You can download and install
                  pywin32 extensions:

                  Download Python for Windows Extensions for free. OLD project page for the Python extensions for Windows. This project has been migrated to github - please visit https://github.com/mhammond/pywin32 Please file all issues via github.


                  then you can run this script:

                  site-packages\win32c omext\axscript\ client\pyscript .py

                  This will register Python as an ActiveX scripting language.
                  Then you can create an ASP page like this (index.asp):

                  <%@ Language=Python %>
                  <%
                  lst = [0,1,2,3]
                  Response.write( str(lst))
                  %>

                  I think it is better (and faster) to use Python as an ActiveX scripting
                  language then to use it as a CGI program.
                  Best,

                  G


                  Comment

                  • Andrew Clover

                    #10
                    Re: Python scripts in IIS

                    Jon Cosby <jcosby@nospam. net> wrote:
                    [color=blue]
                    > Thanks. I had left out the trailing arguments. What is "%s" for, anyway?[/color]

                    It gets substituted with the name of the .py file.

                    Note: you really want -

                    ...python.exe -u %s %s

                    The -u ensures you get binary IO streams, which will become significant if
                    you are receiving file upload fields or returning a non-textual response
                    (ie. file download).

                    --
                    Andrew Clover
                    mailto:and@doxd esk.com

                    Comment

                    • Scott F

                      #11
                      Re: Python scripts in IIS

                      and-google@doxdesk. com (Andrew Clover) wrote in
                      news:2c60a528.0 402250300.17451 bfe@posting.goo gle.com:
                      [color=blue]
                      >
                      > Note: you really want -
                      >
                      > ...python.exe -u %s %s
                      >
                      > The -u ensures you get binary IO streams, which will become
                      > significant if you are receiving file upload fields or returning a
                      > non-textual response (ie. file download).
                      >[/color]

                      Can you reference the documentation for the -u argument?

                      Thanks.

                      Scott

                      Comment

                      • Peter Hansen

                        #12
                        Re: Python scripts in IIS

                        Scott F wrote:[color=blue]
                        >
                        > and-google@doxdesk. com (Andrew Clover) wrote in
                        > news:2c60a528.0 402250300.17451 bfe@posting.goo gle.com:
                        >[color=green]
                        > >
                        > > Note: you really want -
                        > >
                        > > ...python.exe -u %s %s
                        > >
                        > > The -u ensures you get binary IO streams, which will become
                        > > significant if you are receiving file upload fields or returning a
                        > > non-textual response (ie. file download).
                        > >[/color]
                        >
                        > Can you reference the documentation for the -u argument?[/color]

                        "python -h" will show you.

                        Comment

                        • Scott F

                          #13
                          Re: Python scripts in IIS

                          Peter Hansen <peter@engcorp. com> wrote in news:403CCF0C.6 93FBAE2
                          @engcorp.com:[color=blue][color=green]
                          >> Can you reference the documentation for the -u argument?[/color]
                          >
                          > "python -h" will show you.[/color]

                          Right for python, but not for IIS. E.g., in

                          <path>python.ex e %s %s

                          The first %s stands for the script name, and the second %s stands for
                          _all_ the arguments. This is not normal substitution. That's why %s
                          needs to be used, not even %S (capitalized).

                          Actually, Robert Brewer's response is more to the point. Security is
                          more troublesome with the above.

                          Comment

                          • Peter Hansen

                            #14
                            Re: Python scripts in IIS

                            Scott F wrote:[color=blue]
                            >
                            > Peter Hansen <peter@engcorp. com> wrote in news:403CCF0C.6 93FBAE2
                            > @engcorp.com:[color=green][color=darkred]
                            > >> Can you reference the documentation for the -u argument?[/color]
                            > >
                            > > "python -h" will show you.[/color]
                            >
                            > Right for python, but not for IIS.[/color]

                            Wasn't the -u used as an option to Python in the example you were
                            asking about?

                            Andy had written this (re-posted here for reference):
                            [color=blue][color=green]
                            > > Note: you really want -
                            > >
                            > > ...python.exe -u %s %s[/color][/color]

                            Looks like a Python option to me, not an IIS one...

                            -Peter

                            Comment

                            Working...