467,920 Members | 1,218 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,920 developers. It's quick & easy.

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
Jul 18 '05 #1
  • viewed: 2989
Share:
13 Replies
Jon Cosby wrote:

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?


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
Jul 18 '05 #2
"Peter Hansen" <pe***@engcorp.com> wrote
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?
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


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

Jon
Jul 18 '05 #3
Jon Cosby wrote:

"Peter Hansen" <pe***@engcorp.com> wrote
Without more detail, I doubt anyone can help much more.


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


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
Jul 18 '05 #4
"Peter Hansen" <pe***@engcorp.com> wrote
Jon Cosby wrote:

"Peter Hansen" <pe***@engcorp.com> wrote
Without more detail, I doubt anyone can help much more.


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


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...


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
Jul 18 '05 #5
"Jon Cosby" <jc****@nospam.net> wrote in
news:aH*****************@newsread1.news.pas.earthl ink.net:

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.


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
Jul 18 '05 #6

"Scott F" <sdfATexpertuneDOTcom> wrote

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.


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.

Thanks. I had left out the trailing arguments. What is "%s" for, anyway?

Jon
Jul 18 '05 #7
"Jon Cosby" <jc****@nospam.net> wrote in
news:6D*****************@newsread1.news.pas.earthl ink.net:
Thanks. I had left out the trailing arguments. What is "%s" for,
anyway?


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

Scott
Jul 18 '05 #8

Jon Cosby wrote:
"Scott F" <sdfATexpertuneDOTcom> wrote

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.

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.

Thanks. I had left out the trailing arguments. What is "%s" for, anyway?

Jon

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:

https://sourceforge.net/projects/pywin32/

then you can run this script:

site-packages\win32comext\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
Jul 18 '05 #9
Jon Cosby <jc****@nospam.net> wrote:
Thanks. I had left out the trailing arguments. What is "%s" for, anyway?


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:an*@doxdesk.com
http://www.doxdesk.com/
Jul 18 '05 #10
an********@doxdesk.com (Andrew Clover) wrote in
news:2c**************************@posting.google.c om:

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).


Can you reference the documentation for the -u argument?

Thanks.

Scott
Jul 18 '05 #11
Scott F wrote:

an********@doxdesk.com (Andrew Clover) wrote in
news:2c**************************@posting.google.c om:

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).


Can you reference the documentation for the -u argument?


"python -h" will show you.
Jul 18 '05 #12
Peter Hansen <pe***@engcorp.com> wrote in news:403CCF0C.693FBAE2
@engcorp.com:
Can you reference the documentation for the -u argument?


"python -h" will show you.


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

<path>python.exe %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.

Jul 18 '05 #13
Scott F wrote:

Peter Hansen <pe***@engcorp.com> wrote in news:403CCF0C.693FBAE2
@engcorp.com:
Can you reference the documentation for the -u argument?


"python -h" will show you.


Right for python, but not for IIS.


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):
Note: you really want -

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


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

-Peter
Jul 18 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Shufen | last post: by
8 posts views Thread by Jan Danielsson | last post: by
6 posts views Thread by Ishpeck | last post: by
24 posts views Thread by Mark | last post: by
reply views Thread by ashish | last post: by
2 posts views Thread by joe jacob | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.