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

Ronald Oussoren oussoren at cistron.nl
Fri Oct 24 06:15:33 EDT 2003


What version of pyton do you use? Python 2.3 includes a module named  
cgitb that would be usefull here. At the top of you script add: import  
cgitb; cgitb.enable().  You will then be able to see the exceptions  
generated by your CGI-script.



Ronald

On 24 okt 2003, at 10:23, Eric Wichterich wrote:

> 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}
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 3295 bytes
Desc: not available
Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20031024/d92d0942/attachment.bin


More information about the Pythonmac-SIG mailing list