[Python-au] Windows Python different than Linux Python
Mike Dewhirst
miked at dewhirst.com.au
Tue Oct 11 09:39:59 CEST 2005
Graham Dumpleton wrote:
> Check the first line of your .py file. When running as CGI on UNIX it
> would need a #! line as first line to indicate the interpreter to run to
> interpret the remainder of the file. On UNIX systems this is often
> written as:
>
> #!/usr/bin/env python
>
> This though wouldn't necessarily be appropriate on Win32 presuming that
> still comes into play.
>
> I don't actually use Win32, so hope this is of help, but have seen
> issues with this for people going from Win32 to UNIX and where the line
> wasn't correct.
>
> Graham
>
Graham and Wilson - thanks for the quick response. I've been trying things.
My Python is installed in Windows in c:\usr\bin which is also where it
is in SuSE Linux. I did that because I want to run the scripts unchanged
on either platform.
My shebang line is #!/usr/bin/python
In the /srv/www/cgi-bin/ directory in a bash shell 'which python' gives
me /usr/bin/python which exactly matches #!/usr/bin/python
./test_regid.py fails with : bad interpreter : No such file or directory
However in the same directory, 'python test_regid.py' runs all the unit
tests successfully. In fact all the unit tests for all scripts run fine.
I was logged in as mdewhirst and have myself in the www group. I get
identical results when logged in as root.
I wrote the scripts in Windows. Would they have \r\n line endings which
are stuffing up the shebang lines??
Mike
> Wilson Afonso wrote:
>> On 11/10/05, Mike Dewhirst <miked at dewhirst.com.au> wrote:
>>
>>>Does import work differently in Linux (python 2.3) than Windows (python
>>>2.4) ???
>>>[...]
>>>... and all works fine with Apache 2.0.54 on Tosh. Under SuSE 9.1 linux,
>>>it doesn't. Apache 2.0.53 is giving an error (see below) which Mr Google
>>>indicates is a bad path to a file. All the scripts including fcrypt are
>>>in the same /srv/www/cgi-bin/ directory and the above imports must
>>>surely be on the path somewhere.
>>
>>
>> The error doesn't look like import is failing; the problem happens
>> before the script even starts. This error:
>>
>>
>>>[Tue Oct 11 14:18:32 2005] [error] [client 192.168.0.22] (2)No such file
>>>or directory: exec of '/srv/www/cgi-bin/collect.py' failed, referer:
>>>http://192.168.0.11/collect_pczen.html
>>
>>
>> means that Apache failed to open the script. That either means that
>> /srv/www/cgi-bin/collect.py does not exist, or that the web server has
>> no permissions to open it, or that it specifies an interpreter which
>> does not exist (in the first line of the script, starting with "#!").
>> The script never started, to Python never had a chance to do an
>> 'import'.
>>
>> Can you cd into that directory and run "./collect.py"? If so, does the
>> web server have permissions to do the same (not only for the script,
>> but for all the directories in the path)? If not, check that the path
>> to Python is correct inside the script. From your description, I'm
>> betting on a wrong path to Python as the most likely cause of the
>> problem (as you say other scripts in the same directory run
>> correctly).
>>
>> -Wilson
>> --
>> Wilson Roberto Afonso wafonso at gmail.com
>> http://www.netwhatever.com/
>>
>>
>
More information about the python-au
mailing list