Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: No Module Named 'pysqlite2'

I have written a program in Python which was done on windows. And in the windows test environment worked fine. Now I am setting up a linux server to internally host the program. I have installed all the dependencies etc from a generated requirements file but when I run it I come on a problem,

ImportError: No Module Named 'pysqlite2'.

I have extensively googled this issue and have not found a solution. Can anyone tell me how to fix this problem from code below? I cannot upload an image due to reputation isnt high enough. Any help would be greatly appreciated. If any other information is needed just comment and I will upload.

File "/home/ryan/python_p/venv/lib/python3.4/site-packages/sqlalchemy/dialects/sqlite/pysqlite.py", line 334, in dbapi
    from pysqlite2 import dbapi2 as sqlite
ImportError: No Module named 'pysqlite2'

As far as I understand it sqlite either is not compatible or has compatibility issues?

Another issue that I think is directly related is when inside the virtual environment and I try pip3.4 install pysqlite i get

SyntaxError: Missing Parenthesis in call to 'Print

Its suggests install Sphinx which I did but did not cure.

I think these two issues are directly related and by curing ine should be able to cure the other.

like image 883
Ryan McKinney Avatar asked Apr 21 '15 11:04

Ryan McKinney


People also ask

Why does pip install pysqlite fail to install?

Executing pip install pysqlite directly would result in a gcc error, you would have to yum install sqlite-devel first, before installing pysqlite. After that, ImportError may still persist, if you are using a Python version different from the Python 2.6 that's shipped with CentOS 6.

Is it possible to use pysqlite in Python 3?

pysqlite is not supported on Python 3. When using Python 3, use the sqlite3 module from the standard library. Python 3.6.3 :: Anaconda, Inc. 3.20.1 2017-08-24 16:21:36

Why can't I add SQLite to my Python project?

You are likely to be missing sqlite binding for your python install (that come with python, not as python a package) Maybe a install libsqlite3-dev as suggested here.

Is it possible to use pysqlite instead of stdlib SQLite?

Sorry, something went wrong. pysqlite is only used as a fallback when stdlib sqlite is unavailable, which normally only happens when Python has itself not been built properly.


1 Answers

You could probably just use sqlite3 which is now part of the standard library and should work exactly the same as pysqlite2 does. You can try to modify the file mentioned from:

from pysqlite2 import dbapi2 as sqlite

to

from sqlite3 import dbapi2 as sqlite
like image 158
Stefan Avatar answered Oct 19 '22 13:10

Stefan