ModuleNotFoundError: No module named 'pysqlite2' when I run jupyter notebook

I'm using debian 12 I created a virtual environment using virtualenv in ~/.venv Then I installed jupyter notebook with pip install jupyter Now I run jupyter notebook and it throws this error

(.venv) marcelaar@marcel:~$ jupyter notebook
Traceback (most recent call last):
  File "/home/marcelaar/.venv/lib/python3.11/site-packages/jupyter_server/services/sessions/sessionmanager.py", line 14, in <module>
    import sqlite3
  File "/usr/lib/python3.11/sqlite3/__init__.py", line 57, in <module>
    from sqlite3.dbapi2 import *
  File "/usr/lib/python3.11/sqlite3/dbapi2.py", line 27, in <module>
    from _sqlite3 import *
ImportError: /usr/lib/python3.11/lib-dynload/_sqlite3.cpython-311-x86_64-linux-gnu.so: undefined symbol: sqlite3_enable_load_extension

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/marcelaar/.venv/bin/jupyter-notebook", line 5, in <module>
    from notebook.app import main
  File "/home/marcelaar/.venv/lib/python3.11/site-packages/notebook/app.py", line 17, in <module>
    from jupyter_server.serverapp import flags
  File "/home/marcelaar/.venv/lib/python3.11/site-packages/jupyter_server/serverapp.py", line 107, in <module>
    from jupyter_server.gateway.managers import (
  File "/home/marcelaar/.venv/lib/python3.11/site-packages/jupyter_server/gateway/managers.py", line 33, in <module>
    from ..services.sessions.sessionmanager import SessionManager
  File "/home/marcelaar/.venv/lib/python3.11/site-packages/jupyter_server/services/sessions/sessionmanager.py", line 17, in <module>
    from pysqlite2 import dbapi2 as sqlite3  # type:ignore[no-redef]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'pysqlite2'

I also tried to install pysqlite2 with pip install pysqlite2 but I got

ERROR: Could not find a version that satisfies the requirement pysqlite2 (from versions: none)
ERROR: No matching distribution found for pysqlite2

Even I tried to open the python interpreter of the virtual environment and import by myself pysqlite2 and sqlite3 modules. I found in internet that sqlite3 comes by default with python but I got an error when I imported sqlite3

Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] 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/lib/python3.11/sqlite3/__init__.py", line 57, in <module>
    from sqlite3.dbapi2 import *
  File "/usr/lib/python3.11/sqlite3/dbapi2.py", line 27, in <module>
    from _sqlite3 import *
ImportError: /usr/lib/python3.11/lib-dynload/_sqlite3.cpython-311-x86_64-linux-gnu.so: undefined symbol: sqlite3_enable_load_extension
>>> 

I just want to open jupyter notebook without problems Thanks for any help!

Upvotes: 3

Views: 1814

Answers (1)

Tej Dave
Tej Dave

Reputation: 1

I was using anaconda as package manager, so installing pysqlite3 package resolved the notebook issue for me.

Upvotes: 0

Related Questions