Jupyter notebook does not launch (ImportError: DLL load failed while importing)

Question:

Recently my jupyter notebook stopped launching. When I try the command jupyter notebook from anaconda prompt but it gives error

Traceback (most recent call last):
File "C:UsersDellanaconda3Scriptsjupyter-notebook-script.py", line 6, in
from notebook.notebookapp import main
File "C:UsersDellanaconda3libsite-packagesnotebooknotebookapp.py", line 51, in
from zmq.eventloop import ioloop
File "C:UsersDellanaconda3libsite-packageszmq_init_.py", line 50, in
from zmq import backend
File "C:UsersDellanaconda3libsite-packageszmqbackend_init_.py", line 40, in
reraise(*exc_info)
File "C:UsersDellanaconda3libsite-packageszmqutilssixcerpt.py", line 34, in reraise
raise value
File "C:UsersDellanaconda3libsite-packageszmqbackend_init_.py", line 27, in
ns = select_backend(first)
File "C:UsersDellanaconda3libsite-packageszmqbackendselect.py", line 28, in select_backend
mod = import(name, fromlist=public_api)
File "C:UsersDellanaconda3libsite-packageszmqbackendcython_init
.py", line 6, in
from . import (constants, error, message, context,
ImportError: DLL load failed while importing error: The specified module could not be found.

I even tried reinstalling anaconda and upgraded to python 3.8.3 on windows 10 but still get the same error. When I tried to check jupyter notebook’s version it said that ipykernel and some other things were not installed. jupyter --version gives me this:

jupyter core : 4.6.3
jupyter-notebook : 6.1.1
qtconsole : 4.7.6
ipython : 7.18.1
ipykernel : not installed
jupyter client : not installed
jupyter lab : not installed
nbconvert : 5.6.1

But installing ipykernel with conda install ipykernel says

All requested packages already installed.

I also tried ipython kernel install --name <env_name> --user but this gives another dll error.

Reading some other problems in stackoverflow I went and checked my enviroment variables.

System Variables

User Variables

Is there a problem with this environment variable. Please help.

Screenshot of the anaconda prompt with error.
Screenshot of the anaconda prompt

Edit: The anaconda navigator does not launch either. anaconda-navigator on the anaconda prompt gives another error:
Anaconda navigator error

I also tried:

conda install qt --force
conda install pyqt --force

But that did’nt help. Does previously installed anaconda cause such error?

Asked By: Anav Katwal

||

Answers:

Use this code, instead of conda

pip install jupyter
Answered By: Ganesh

I found what I did wrong (silly me). Microsoft visual C++ 2015-2019 was somehow removed when I tried to install openCV manually. Didn’t think that such an install would make such big impact, have to keep that in mind now but installing the latest solved all the problems.

P.S.: This solution might not work for someone else with similar problem. But its worth taking a note.

Answered By: Anav Katwal

Just for other people having similar issue.

In my case, when I run jupyter notebook on command line, I got the same error as @Anav Katwal . However if I run jupyter notebook on Anaconda Prompt, then the error is gone.

If you truly want to execute jupyter notebook on cmd, then you could add the following paths to your system environment variable:

  • C:UsersUSERNAMEanaconda3Librarybin
  • C:UsersUSERNAMEanaconda3Scripts
  • C:UsersUSERNAMEanaconda3condabin
Answered By: johnnyasd12

What worked for me was reinstalling one of the modules jupyter calls and reinstalling the newer version manually, via another SO answer:

pip uninstall pyzmq 
pip install pyzmq==20

Import error while trying to run jupyter notebook

Answered By: remsky

step 1 : close anaconda and vscode

step 2 : open command prompt (cmd) and uninstall jupyter lab

pip uninstall jupyterlab

step 3: now open jupyter lab type

jupyter-lab

Now open vs code jupyter notebook start working

Answered By: Mahesh