3

I'm using Debian "Linux mint 19.1" and python 3.7.4 and system have already 2.7 & 3.6 versions. I create an env but when I start to create database file with db.create_all() I have "...

ModuleNotFoundError: No module named '_sqlite3' "

I have try by installing this packages [ quick-sqlite , pysqlite3 ]

db.create_all() Traceback (most recent call last): File "/media/gabalawy/projetcs/training/Flask_Blog/env3.7/lib/python3.7/site-packages/sqlalchemy/dialects/sqlite/pysqlite.py", line 338, in dbapi from pysqlite2 import dbapi2 as sqlite ModuleNotFoundError: No module named 'pysqlite2'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "", line 1, in File "/media/gabalawy/projetcs/training/Flask_Blog/env3.7/lib/python3.7/site-packages/flask_sqlalchemy/init.py", line 1033, in create_all self._execute_for_all_tables(app, bind, 'create_all') File "/media/gabalawy/projetcs/training/Flask_Blog/env3.7/lib/python3.7/site-packages/flask_sqlalchemy/init.py", line 1025, in _execute_for_all_tables op(bind=self.get_engine(app, bind), **extra) File "/media/gabalawy/projetcs/training/Flask_Blog/env3.7/lib/python3.7/site-packages/flask_sqlalchemy/init.py", line 956, in get_engine return connector.get_engine() File "/media/gabalawy/projetcs/training/Flask_Blog/env3.7/lib/python3.7/site-packages/flask_sqlalchemy/init.py", line 561, in get_engine self._engine = rv = self._sa.create_engine(sa_url, options) File "/media/gabalawy/projetcs/training/Flask_Blog/env3.7/lib/python3.7/site-packages/flask_sqlalchemy/init.py", line 966, in create_engine return sqlalchemy.create_engine(sa_url, **engine_opts) File "/media/gabalawy/projetcs/training/Flask_Blog/env3.7/lib/python3.7/site-packages/sqlalchemy/engine/init.py", line 435, in create_engine return strategy.create(*args, **kwargs) File "/media/gabalawy/projetcs/training/Flask_Blog/env3.7/lib/python3.7/site-packages/sqlalchemy/engine/strategies.py", line 87, in create dbapi = dialect_cls.dbapi(**dbapi_args) File "/media/gabalawy/projetcs/training/Flask_Blog/env3.7/lib/python3.7/site-packages/sqlalchemy/dialects/sqlite/pysqlite.py", line 343, in dbapi raise e File "/media/gabalawy/projetcs/training/Flask_Blog/env3.7/lib/python3.7/site-packages/sqlalchemy/dialects/sqlite/pysqlite.py", line 341, in dbapi from sqlite3 import dbapi2 as sqlite # try 2.5+ stdlib name. File "/usr/local/lib/python3.7/sqlite3/init.py", line 23, in from sqlite3.dbapi2 import * File "/usr/local/lib/python3.7/sqlite3/dbapi2.py", line 27, in from _sqlite3 import * ModuleNotFoundError: No module named '_sqlite3'

2 Answers 2

3

I have Installed "pysqlite3"

pip install pysqlite3

and modify

"/site-packages/sqlalchemy/dialects/sqlite/pysqlite.py", line 341

from sqlite3 import dbapi2 as sqlite  # try 2.5+ stdlib name.

to

from pysqlite3 import dbapi2 as sqlite  # try 2.5+ stdlib name.
Sign up to request clarification or add additional context in comments.

Comments

0

I believe that the _sqlite3 import is an internal import and should be available from your standard python installation. The fact that it's missing suggests a problem with your python build (did you compile it yourself).

I was able to fix this on suse by first ensuring that the ncurses were installed and then installing:

zypper install python-curses

On ubunti I guess the equivalent is (although I'm not sure its absence would give the same error):

sudo apt-get install libncursesw5-dev

(my complete build pre-requisites are:

sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

)

Comments

Your Answer

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.