No module named pysqlite2._sqlite Error with flask

2019-09-09 13:26发布

问题:

Hi I m have a problem with No module named pysqlite2._sqlite error

I m using SQLalchemy with flask and virtualenv

when i query by model like this

user  = User.query.filter_by(social_id = social_id).first()

i got the following error

No module named pysqlite2._sqlite

First error was

No module named pysqlite2

So i install the pysqlite by pip install pysqlite

I try to reinstall the pysqlite by

pip uninsatll pysqlite
pip install pysqlite

But the same problem is ouccuring

And i check the sqlahcemy code, it import module like this

from pysqlite2 import dbapi2 

But at the console

from pysqlite2 import dbapi2

is working.

So i check the pysqlite2 library folder

I found that there is _sqlite.so file.

What is the problem?

回答1:

I find the problem

Error occur from the google app engine environment

Google app engine doesn't provide c compiled library.

sqlite has c complied file, so it can't import module