11

trying to get jupyter (ipython3) running on Python3.5, I installed it using

sudo pip3 install jupyter

However, when trying to launch jupyter notebook I receive the error that the modules _sqlite3 and pysqlite2 are missing. I tried installing them via pip3. For pysqlite2 there seems to be no version availabel (?). For sqlite3 I get

RuntimeError: Package 'sqlite3' must not be downloaded from pypi

Traceback (most recent call last):   File "/usr/local/lib/python3.5/site-packages/notebook/services/sessions/sessionmanager.py", line 10, in <module>
    import sqlite3   File "/usr/local/lib/python3.5/sqlite3/__init__.py", line 23, in <module>
    from sqlite3.dbapi2 import *   File "/usr/local/lib/python3.5/sqlite3/dbapi2.py", line 27, in <module>
    from _sqlite3 import * ImportError: No module named '_sqlite3'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/bin/jupyter-notebook", line 7, in <module>
    from notebook.notebookapp import main
  File "/usr/local/lib/python3.5/site-packages/notebook/notebookapp.py", line 79, in <module>
    from .services.sessions.sessionmanager import SessionManager
  File "/usr/local/lib/python3.5/site-packages/notebook/services/sessions/sessionmanager.py", line 13, in <module>
    from pysqlite2 import dbapi2 as sqlite3
ImportError: No module named 'pysqlite2'

Any ideas?

Suppenkasper
  • 845
  • 4
  • 10
  • 29

4 Answers4

14

I was missing libsqlite3-dev when building Python3. So after running sudo apt-get install libsqlite3-dev and rebuilding Python3 everything seems to work now.

Suppenkasper
  • 845
  • 4
  • 10
  • 29
  • 2
    Worked for me. Installed the appropriate package (for Fedora) and compiled [as instructed here](https://stackoverflow.com/questions/41489439/pip3-installs-inside-virtual-environment-with-python3-6-failing-due-to-ssl-modul). – Roman Luštrik Feb 22 '18 at 15:59
7

I am on Centos 7 and built Python3.8 from source. Indeed as Suppenkasper said I needed to first sudo yum install libsqlite3x-devel.x86_64 before rebuilding Python3.8 using sudo make altinstall.

You can find the exact sqlite package name through yum list | grep sqlite.

John Jiang
  • 827
  • 1
  • 9
  • 19
1

I got the same error in jupyter notebook. I have installed python 3.7.2 from source in my tmp folder in Ubuntu 16.04.7 LTS (Xenial Xerus). It was missing libsqlite3-dev So first install libsqlite3-dev using

$ sudo apt-get install libsqlite3-dev

Then rebuild your python 3.7.2, to do this go to your python installed folder in my case /tmp/python-3.7.2 and run

$ cd /tmp/Python-3.7.2
$ ./configure --enable-optimizations
$ sudo make altinstall
Amit Kumar
  • 619
  • 7
  • 10
0

I have to reinstall the python and it works again.

Richter
  • 164
  • 2
  • 6