Re: Python, CGI and Sqlite3

2010-04-13 Thread Tim Chase

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







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


RE: Python, CGI and Sqlite3

2010-04-13 Thread Ahmed, Shakir
-Original Message-
From: python-list-bounces+shahmed=sfwmd@python.org
[mailto:python-list-bounces+shahmed=sfwmd@python.org] On Behalf Of
Tim Chase
Sent: Tuesday, April 13, 2010 2:36 PM
To: Majdi Sawalha
Cc: python-list@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

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