Error in python3.6 sqlite3

I installed Python3.6 on ubuntu16.04 and installed sqlite3. When in python2 I can import sqlite successfully, but in python3 I got an import error. I tried many methods from Google, but it still does not work. I want to know how to solve it.

Python 3.6.0 (default, Mar 13 2017, 06:38:19) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. > import sqlite3 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.6/sqlite3/__init__.py", line 23, in <module> from sqlite3.dbapi2 import * File "/usr/local/lib/python3.6/sqlite3/dbapi2.py", line 27, in <module> from _sqlite3 import * ModuleNotFoundError: No module named '_sqlite3' 
+5
source share
1 answer

You can install python3 and sqlite yourself. try it.

Or you can try it as follows:

  1. install sqlite3
 $ wget https://www.sqlite.org/2017/sqlite-autoconf-3170000.tar.gz --no-check-certificate
 $ tar zxvf sqlite-autoconf-3170000.tar.gz
 $ cd sqlite-autoconf-3170000
 $ ./configure --prefix = / usr / local / sqlite3 --disable-static --enable-fts5 --enable-json1 CFLAGS = "- g -O2 -DSQLITE_ENABLE_FTS3 = 1 -DSQLITE_ENABLE_FTS4 = 1 -DSQLITE_ENABLE_RTREE = 1"

 2.install python3.6
 $ cd Python-3.6.0 
 $ LD_RUN_PATH = / usr / local / sqlite3 / lib ./configure --prefix = / usr / local / python3.6 LDFLAGS = "- L / usr / local / sqlite3 / lib" CPPFLAGS = "- I / usr / local / sqlite3 / include "
 $ LD_RUN_PATH = / usr / local / sqlite3 / lib make
 $ LD_RUN_PATH = / usr / local / sqlite3 / lib make install 

+2
source

Source: https://habr.com/ru/post/1265390/


All Articles