[Pythonmac-SIG] How to import libraries on Mac OS X?

Eric Wichterich eric.wichterich at gmx.de
Fri Oct 24 04:23:50 EDT 2003


Yes, there is a sh-bang at the top of the script:
#!/usr/local/bin/python

The script runs if I comment the statement "from name_of_library import  
special_function" out (except the error because of the missing  
functions which are in the library ;) ).

The Apache-Config is set to allow cgis to execute in that directory.
<Directory "/Users/projectname/Sites/">
     Options Indexes ExecCGI MultiViews
     AllowOverride None
     Order allow,deny
     Allow from all
</Directory>



Am Freitag, 24.10.03 um 05:20 Uhr schrieb Sarwat Khan:

> Do you have a sh-bang at the top of your script? Like
>
> #! /usr/bin/env python
>
> I don't think your script is running as a Python script. You might  
> want to take a look at the Python CGI FAQ here,
>
> http://starship.python.net/crew/davem/cgifaq/ 
> faqw.cgi?req=show&file=faq01.001.htp
>
> On Thursday, October 23, 2003, at 04:08  PM, Eric Wichterich wrote:
>
>> Hello Sarwat,
>>
>> the entry of the error_log is:
>> [Thu Oct 23 21:54:46 2003] [error] [client 123.456.654.321] malformed  
>> header from script. Bad header=  from name_of_library impo:  
>> /Users/username/Sites/projectname/cgi-bin/script.cgi
>>
>> The files were set to chmod "755".
>>
>> Greetings,
>> Eric
>>
>> Am Donnerstag, 23.10.03 um 19:57 Uhr schrieb Sarwat Khan:
>>
>>> You should check /var/log/httpd/error_log for a description of the  
>>> error.
>>>
>>> What's likely to be happening is that when you try to import your  
>>> library, Python writes an error to out, and Apache sees this instead  
>>> of the standard HTTP header text that's supposed to be printed. So  
>>> Apache prints the malformed header stuff.
>>>
>>> You might want to make sure that the files in cgi-bin are world  
>>> readable, and that cgi-bin are world-executable (searchable).
>>>
>>> On Thursday, October 23, 2003, at 05:07  AM, Eric Wichterich wrote:
>>>
>>>> Hello Pythonistas,
>>>>
>>>> I've written a Python library with some functions I want to use  
>>>> with other Python scripts.
>>>> The library is located at (Mac OS X):
>>>> /Users/username/Sites/projectname/cgi-bin/name_of_library.py
>>>> (My scripts are located in this directory, too.)
>>>>
>>>> I use the statement:  "from name_of_library import  
>>>> special_function" to import this special_function.
>>>>
>>>> When I launch the Apache-Server and call a script which wants to  
>>>> import this library, I get a "malformed header" error.
>>>>
>>>> But importing standard libraries, such as "from string import *",  
>>>> no error occurs.
>>>>
>>>> Maybe some environment variables must be set. But which? Any ideas?
>>>>
>>>> Thank you,
>>>> Eric
>>>> _______________________________________________
>>>> Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
>>>> http://mail.python.org/mailman/listinfo/pythonmac-sig
>>>>
>>>
>>> {sarwat khan : http://sarwat.net}
>>>
>
> {sarwat khan : http://sarwat.net}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 2881 bytes
Desc: not available
Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20031024/20540466/attachment.bin


More information about the Pythonmac-SIG mailing list