ImportError: No module named 'pysqlite2'

5,820 views
Skip to first unread message

T. Dalton Combs

unread,
Sep 6, 2015, 1:10:07 PM9/6/15
to Project Jupyter
I'm using a nitrc ubuntu server, and I'm able to follow the installation guide. But when I type jupyterhub in to the command line i get the error :

tdaltonc@nitrcce:~$ jupyterhub

[I 2015-09-06 17:01:31.361 JupyterHub app:518] Loading cookie_secret from /home/tdaltonc/jupyterhub_cookie_secret

[E 2015-09-06 17:01:31.377 JupyterHub app:1097]

    Traceback (most recent call last):

      File "/usr/local/lib/python3.4/site-packages/jupyterhub/app.py", line 1094, in launch_instance_async

        yield self.initialize(argv)

      File "/usr/local/lib/python3.4/site-packages/jupyterhub/app.py", line 909, in initialize

        self.init_db()

      File "/usr/local/lib/python3.4/site-packages/jupyterhub/app.py", line 585, in init_db

        **self.db_kwargs

      File "/usr/local/lib/python3.4/site-packages/jupyterhub/orm.py", line 507, in new_session_factory

        engine = create_engine(url, **kwargs)

      File "/usr/local/lib/python3.4/site-packages/sqlalchemy/engine/__init__.py", line 386, in create_engine

        return strategy.create(*args, **kwargs)

      File "/usr/local/lib/python3.4/site-packages/sqlalchemy/engine/strategies.py", line 75, in create

        dbapi = dialect_cls.dbapi(**dbapi_args)

      File "/usr/local/lib/python3.4/site-packages/sqlalchemy/dialects/sqlite/pysqlite.py", line 339, in dbapi

        raise e

      File "/usr/local/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'


I've googled around a lot but can't find anything that helps. Any advice?


Matthias Bussonnier

unread,
Sep 6, 2015, 1:41:58 PM9/6/15
to jup...@googlegroups.com
what does the following say in a Python 3.4 prompt :

from sqlite3 import dbapi2 as sqlite
> --
> You received this message because you are subscribed to the Google Groups
> "Project Jupyter" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jupyter+u...@googlegroups.com.
> To post to this group, send email to jup...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jupyter/4191b086-e32a-48db-9b21-5bc3b2e749d6%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

T. Dalton Combs

unread,
Sep 6, 2015, 3:18:54 PM9/6/15
to Project Jupyter
It does not complain about "from sqlite3 import dbapi2 as sqlite ". 

I think I solved the problem. I needed to compile my own copy of Python3.4 (the server only came with 2.7 & 3.2). And at the compile time, I hadn't installed libsqlite3-dev. 
I started over with a fresh instance of the nitrc ami and this time installed libsqlite3-dev before compiling python3.4 and everything is ok now. 

Also though, my apt-get wasn't able to find nodejs-legacy (per the installation instructions on github). I had to download this PPA: 
curl -sL https://deb.nodesource.com/setup | sudo bash -

and then "apt-get install nodejs". (instructions here)
 I just wanted to write that down incase anyone else has that same problem.  

T. Dalton Combs

unread,
Sep 6, 2015, 3:20:39 PM9/6/15
to Project Jupyter
Let me know if you'd like any other info for documentation. 

MinRK

unread,
Sep 7, 2015, 3:12:31 AM9/7/15
to jup...@googlegroups.com
Thanks for reporting this. It is typically a safe assumption that sqlite3 is available from the standard library. The exception to this is when users compile Python themselves, they can easily end up without it due to missing dependencies at build time (I still think Python should refuse to build without sqlite unless a `--without-sqlite` flag is explicitly given). To cover the case of misconfigured Python, there is a pip-installable package, pysqlite2, which provides the same API as the stdlib package. If you have built Python without sqlite3, you can install pysqlite2 later and it should work.

-MinRK

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.

Andrew Artajos

unread,
Nov 24, 2015, 12:40:21 AM11/24/15
to Project Jupyter

Do you use virtual environments?

When I compile my python3 from source, how would I include it to my existing virtual environment?

Andrew

niko Shia

unread,
Sep 24, 2016, 10:37:08 PM9/24/16
to Project Jupyter
i simply opened vi /usr/local/lib/python3.5/site-packages/notebook/services/sessions/sessionmanager.py  and changed lines 10,11,12 as below:

try:
    import sqlite3
except ImportError:
#    fallback on pysqlite2 if Python was build without sqlite
#    from pysqlite2 import dbapi2 as sqlite3
        print("hi")

after that jupyter worked like a charm ;)

Thomas Kluyver

unread,
Sep 25, 2016, 4:41:07 AM9/25/16
to Project Jupyter
I'm puzzled if that change appeared to fix anything, because it should either make no difference (if sqlite3 is available), or leave Jupyter unable to start kernels.
Reply all
Reply to author
Forward
0 new messages