[Tutor] sqlite3 import problem

Matthew Ngaha chigga101 at gmail.com
Fri Jan 3 14:17:31 CET 2014


On Fri, Jan 3, 2014 at 10:36 AM, Alan Gauld <alan.gauld at btinternet.com> 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 ...

Hi Alan. The code in the traceback is being done internally. my code
has "import sqlite3". Python finds it in this directory:

/usr/local/lib/python3.3/sqlite3/

and runs the code from the traceback. I have no idea why it's using _sqlite3:(

On Fri, Jan 3, 2014 at 6:12 AM, Kushal Kumaran
<kushal.kumaran+python at gmail.com> wrote:
> The /usr/local heirarchy is not used by official debian/ubuntu packages,
> so other people will not have the same contents in there as you.  You
> must have a locally built python in /usr/local.  Check the build logs if
> it has complained about not being able to build the sqlite3 module.  If
> so, you can install all build dependencies for the offical python3
> package by running this command:
>
> # apt-get build-dep python3
>
> And then rebuilding your local python3 installation.
>

On Fri, Jan 3, 2014 at 3:00 AM, Danny Yoo <dyoo at hashcollision.org> wrote:
> This might be an Ubuntu bug or deficiency.

Hi, Danny & Kushal.
Originally i only had python 2.7 and 3.2 as default for Ubuntu. Kushal
you're right my 3.2 has a different path to sqlite3 than

/usr/local/lib/python3.3/sqlite3/

Infact i haven't been able to find its location. 3.2 imports sqlite3
with no errors. I'm currently not on ubuntu to try your instruction.
Will the build logs be inside the python3.3 directory? I'm still new
to linux so sorry for newbie questions. it took me a very long time to
get it right when building python3.3. When you say rebuild, is there a
command for doing that or do you mean simply uninstall python then
build it again?

On Fri, Jan 3, 2014 at 10:36 AM, Alan Gauld <alan.gauld at btinternet.com> 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 ...
>
>
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.flickr.com/photos/alangauldphotos
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor


More information about the Tutor mailing list