Re: [Tutor] sqlite3 import problem
On 03/01/14 13:36, Mark Lawrence wrote: File "/usr/local/lib/python3.3/sqlite3/dbapi2.py", line 26, in 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? 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. Yes, but that's usually hidden from the user... I didn't look closely enough at the file names in the traceback and assumed the OP was explicitly importing using the underscore. -- 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@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] sqlite3 import problem
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 from sqlite3.dbapi2 import * File "/usr/local/lib/python3.3/sqlite3/dbapi2.py", line 26, in 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 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] sqlite3 import problem
On Fri, Jan 3, 2014 at 10:36 AM, 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 >> >> from sqlite3.dbapi2 import * >>File "/usr/local/lib/python3.3/sqlite3/dbapi2.py", line 26, in >> 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 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 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 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 >> >> from sqlite3.dbapi2 import * >>File "/usr/local/lib/python3.3/sqlite3/dbapi2.py", line 26, in >> 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@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] sqlite3 import problem
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 from sqlite3.dbapi2 import * File "/usr/local/lib/python3.3/sqlite3/dbapi2.py", line 26, in 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@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] sqlite3 import problem
Matthew Ngaha writes: > im having problems importing sqlite3 on ubuntu python3. > > File "/usr/local/lib/python3.3/sqlite3/__init__.py", line 23, in > from sqlite3.dbapi2 import * > File "/usr/local/lib/python3.3/sqlite3/dbapi2.py", line 26, in > from _sqlite3 import * > ImportError: No module named '_sqlite3' > > i have that path and file (dbapi2.py). the problem is an import > statement for _sqlite3. i don't see this file but shouldn't python3.3 > be able to import sqlite without errors? any suggestions? does anyone > have _sqlite3.py in their /usr/local/lib/python3.3/sqlite3/ > directory? 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. -- regards, kushal pgpqnOrb9Kbe6.pgp Description: PGP signature ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] sqlite3 import problem
Hi Matthew, This might be an Ubuntu bug or deficiency. The file you're looking for is for the underlying low-level C module that bridges the world of SQLite and Python. By all rights, this would have been provided by something like the "python-pysqlite2" package, but that package is for Python 2. I have not been able yet to find the equivalent binary package for Python 3, out of the list in: http://packages.debian.org/search?keywords=python3 and that seems unfortunate. Does anyone with Ubuntu experience know more information about this? >From discussion on Stack Overflow, I see that people have been able to compile Python 3 from scratch and things work: http://stackoverflow.com/questions/8628774/python-3-2-cant-import-sqlite3-module http://superuser.com/questions/557152/sqlite-not-available-with-python-3-3-0-on-debian Frankly, that seems somewhat overkill for the situation, but if you really have to, that's one workaround. It certainly sounds a bit funky: is there something that stops the package developer from having some 'python3-pysqlite2' package? I'm very confused. I'd recommend asking on an Ubuntu-related forum to confirm that this is an Ubuntu or Debian problem, and then hopefully they'll be able to point you in the right direction or get the gears moving to fix this. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] sqlite3 import problem
im having problems importing sqlite3 on ubuntu python3. File "/usr/local/lib/python3.3/sqlite3/__init__.py", line 23, in from sqlite3.dbapi2 import * File "/usr/local/lib/python3.3/sqlite3/dbapi2.py", line 26, in from _sqlite3 import * ImportError: No module named '_sqlite3' i have that path and file (dbapi2.py). the problem is an import statement for _sqlite3. i don't see this file but shouldn't python3.3 be able to import sqlite without errors? any suggestions? does anyone have _sqlite3.py in their /usr/local/lib/python3.3/sqlite3/ directory? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor