Python, CGI and Sqlite3

Ahmed, Shakir shahmed at sfwmd.gov
Tue Apr 13 20:54:30 CEST 2010


-----Original Message-----
From: python-list-bounces+shahmed=sfwmd.gov at python.org
[mailto:python-list-bounces+shahmed=sfwmd.gov at python.org] On Behalf Of
Tim Chase
Sent: Tuesday, April 13, 2010 2:36 PM
To: Majdi Sawalha
Cc: python-list at python.org
Subject: Re: Python, CGI and Sqlite3

On 04/13/2010 12:41 PM, Majdi Sawalha wrote:
> import sqlite3
>
> statement? and it gives the following error
> ImportError: No module named sqlite3,
>
> i tried it on python shell and all statements are work well.

A couple possible things are happening but here are a few that 
pop to mind:

1) you're running different versions of python (sqlite was 
bundled beginning in 2.5, IIRC) so when you run from a shell, you 
get python2.5+ but your CGI finds an older version.  Your CGI can 
dump the value of sys.version which you can compare with your 
shell's version

2) the $PYTHONPATH is different between the two.  Check the 
contents of sys.path in both the shell and the CGI program to see 
if they're the same.  You might also dump the results of 
os.environ.get('PYTHONPATH', None)  to see if an environment 
variable specifies the $PYTHONPATH differently

3) while it reads correctly above, it's theoretically possible 
that you have a spelling error like "import sqllite3"?  I've been 
stung once or twice by this sort of problem so it's not entirely 
impossible :)

-tkc

Tim is right, following import works fine with me.

import sqlite3 






-- 
http://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list