6

sqlite is working fine with python 2.7 but when I am trying to import this in python 3 it gives error

> Traceback (most recent call last): File "dbConnection.py", line 1,
> in <module>
> import sqlite3 File "/usr/local/lib/python3.4/sqlite3/__init__.py", line 23, in <module>
> from sqlite3.dbapi2 import * File "/usr/local/lib/python3.4/sqlite3/dbapi2.py", line 27, in <module>
> from _sqlite3 import * ImportError: No module named '_sqlite3'

to remove this error I am trying to reinstall sqlite3 by

 sudo apt-get install sqlite3

but it says that package is already exists. After that I am trying to install it by

pip3 install sqlite3

but again while installing it gives error

Collecting sqlite3
 Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/sqlite3/
 Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/sqlite3/
 Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fb5ff3bc550>, 'Connection to 196.1.114.80 timed out. (connect timeout=15)')': /simple/sqlite3/
 Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/sqlite3/
 Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/sqlite3/
 Could not find a version that satisfies the requirement sqlite3 (from versions: )
 No matching distribution found for sqlite3

but my connection is working fine ... Now what should I do so that I am able to import sqlite3 in python 3?

Martijn Pieters
1.1m326 gold badges4.2k silver badges3.5k bronze badges
asked Jan 3, 2017 at 9:56

1 Answer 1

8

sqlite3 is an optional part of the standard library. It is compiled when you compile and install Python 3, but only if the right sqlite3 include files (development headers) are available.

If you compiled and installed Python 3 yourself, install the dependencies (libsqlite3-dev or sqlite-devel or similar, depending on your Linux distribution, for example), then re-compile and re-install Python 3.

Externally, the library is maintained as pysqlite; but that release doesn't support Python 3. Even then, to install it you'll still need those sqlite development files, and you'd need to port it to Python 3. You may as well just re-compile Python 3.

answered Jan 3, 2017 at 10:02
Sign up to request clarification or add additional context in comments.

2 Comments

I am using Ubuntu 16.04 and I already installed libsqlite3-dev as suggested by some site but nothing work... :(
Get an error while compiling: *** WARNING: renaming "_sqlite3" since importing it failed: build/lib.linux-x86_64-3.6/_sqlite3.cpython-36m-x86_64-linux-gnu.so: undefined symbol: sqlite3_stmt_readonly From github.com/ghaering/pysqlite/issues/85, it might be caused by the older sqlite version.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.