4
votes

An import error occurs when trying to run jupyter notebook

I'm trying to run jupyter notebook using anaconda (git bash platform), and as I type in jupyter notebook, an import error occurs every time. I tried to lauch it inside an environment, but the same error occured.

$ jupyter notebook

Traceback (most recent call last):

File "C:\Users\User\Anaconda3\Scripts\jupyter-notebook-script.py", line 6, in
 <module>
from notebook.notebookapp import main
File "C:\Users\User\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 47, in <module>
from zmq.eventloop import ioloop
File "C:\Users\User\Anaconda3\lib\site-packages\zmq\__init__.py", line 47, in <module>
from zmq import backend
File "C:\Users\User\Anaconda3\lib\site-packages\zmq\backend\__init__.py", line 40, in <module>
reraise(*exc_info)
File "C:\Users\User\Anaconda3\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
raise value
File "C:\Users\User\Anaconda3\lib\site-packages\zmq\backend\__init__.py", line 27, in <module>
_ns = select_backend(first)
File "C:\Users\User\Anaconda3\lib\site-packages\zmq\backend\select.py", line 27, in select_backend
mod = __import__(name, fromlist=public_api)
File "C:\Users\User\Anaconda3\lib\site-packages\zmq\backend\cython\__init__.py", line 6, in <module>
from . import (constants, error, message, context,
    ImportError: DLL load failed: The specified module could not be found.

EDITED After reinstalling pyzmq (and I tried reinstalling conda too), the following error occurs:

$ jupyter notebook

Traceback (most recent call last): File "C:\Users\User\Anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 10, in import sqlite3

File "C:\Users\User\Anaconda3\lib\sqlite3__init__.py", line 23, in from sqlite3.dbapi2 import *

File "C:\Users\User\Anaconda3\lib\sqlite3\dbapi2.py", line 27, in

from _sqlite3 import *

ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\User\Anaconda3\Scripts\jupyter-notebook-script.py", line 6, in

from notebook.notebookapp import main

File "C:\Users\User\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 86, in

from .services.sessions.sessionmanager import SessionManager

File "C:\Users\User\Anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 13, in

from pysqlite2 import dbapi2 as sqlite3

ModuleNotFoundError: No module named 'pysqlite2'

3
That's python unable to import sqlite3. Can you do that in an interactive interpreter?Stop harming Monica

3 Answers

9
votes

I found a similar issue open on GitHub for zmq. The recommendation by GitHub user harsh23tyagi that seems to work for most is to run the following:

pip uninstall pyzmq
pip install pyzmq
3
votes

Working with conda env, jupyter notebook worked in (base) env but gave the .libzmq error in (my_env). To be able to run notebooks from my_env, this worked for me :

  • pip uninstall pyzmq
  • pip install pyzmq==20 (no version for pyzmq didn't fix the issue for me)
0
votes

It seems that updating pyzmq to the latest version fixes this problem for me.

conda install pyzmq=22