[Tutor] sqlite3 import problem

Mark Lawrence breamoreboy at yahoo.co.uk
Fri Jan 3 14:36:05 CET 2014


On 03/01/2014 10:36, Alan Gauld wrote:
> On 03/01/14 02:17, Matthew Ngaha wrote:
>> im having problems importing sqlite3 on ubuntu python3.
>>
>>    File "/usr/local/lib/python3.3/sqlite3/__init__.py", line 23, in
>> <module>
>>      from sqlite3.dbapi2 import *
>>    File "/usr/local/lib/python3.3/sqlite3/dbapi2.py", line 26, in
>> <module>
>>      from _sqlite3 import *
>> ImportError: No module named '_sqlite3'
>
> As a matter of interest why do you have the underscore in front of
> sqlite3? Is that deliberate?
>
> I normally import it with just
>
> import sqlite3
> or
> from sqlite3 import ...
>

You surprise me Alan, this is an oft used idiom in Python.  A typical 
example would be having a fast C module but if this can't be imported 
fall back to a Python implementation.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence



More information about the Tutor mailing list