[Tutor] python by cgi

nik my.mailing.lists at noos.fr
Thu Sep 30 17:30:31 CEST 2004


ah, well spotted. One version was installed by the mandrake install 
disks (the usr/lib one), the other I did myself since I thought 
upgrading was a good idea before I realised that I wasn't sure of the 
side effects of removing the old one. Now I've no idea of what on my 
system uses which version... I might go for the quick fix right now (why 
not put off something today that you can put off for quite a while more 
until it bites you on the ass again, or something like that :-)  )

many thanks,
nik

Lloyd Kvam wrote:

>On Thu, 2004-09-30 at 10:01, nik wrote:
>  
>
>>hi all,
>>
>>I'm trying to access my firebird database using python and cgi. I've 
>>installed the latest apache web server (on linux), and using a simple 
>>script like;
>>#!/usr/local/bin/python
>>
>>def main():
>>    print "Content-type: text/html"
>>    print
>>    print "<TITLE> Hello, World!</TITLE>"
>>
>>if (__name__ == "__main__"):
>>    main()
>>
>>is working just fine.
>>
>>However, if I add an import kinterbasdb at the start, I get an import error.
>>
>>Using the command line interpreter I don't have a problem though.
>>
>>I'm a bit confused by the sys.path a bit, it seems to vary depending on 
>>how I start python;
>>
>>in command line iterpreter, it's;
>>'', '/usr/lib/python23.zip', '/usr/lib/python2.3', 
>>'/usr/lib/python2.3/plat-linux2', '/usr/lib/python2.3/lib-tk', 
>>'/usr/lib/python2.3/lib-dynload', '/usr/lib/python2.3/site-packages', 
>>'/usr/lib/python2.3/site-packages/Numeric', 
>>'/usr/lib/python2.3/site-packages/gtk-2.0'
>>    
>>
>
>Here Python is installed in /usr/lib
>
>  
>
>>by cgi it's;
>>'/usr/local/apache2/cgi-bin', '/usr/local/lib/python23.zip', 
>>'/usr/local/lib/python2.3', '/usr/local/lib/python2.3/plat-linux2', 
>>'/usr/local/lib/python2.3/lib-tk', 
>>'/usr/local/lib/python2.3/lib-dynload', 
>>'/usr/local/lib/python2.3/site-packages'
>>
>>    
>>
>
>Here Python is installed in /usr/local/lib
>
>You have two installed versions of Python.  I would assume that
>kinterbasdb is in /usr/lib AND not in /usr/local/lib.
>
>Quick fix is to install kinterbasdb into the other python.  Better is to
>get down to a single Python2.3 - presumably remove the /usr/local/lib
>version, but that depends on the nature of your linux setup.
>
>
>  
>
>>however, the difference doesn't seem to imply why kinterbasdb can't be 
>>imported.
>>
>>I tried doing
>>import sys
>>sys.path.append('/usr/lib/python2.3/site-packages/kinterbasdb')
>>
>>in the script, but it didn't help.
>>
>>
>>Any ideas? Is it a permissions thing perhaps?
>>
>>nik
>>_______________________________________________
>>Tutor maillist  -  Tutor at python.org
>>http://mail.python.org/mailman/listinfo/tutor
>>    
>>



More information about the Tutor mailing list