When I try to run the command jupyter-notebook
, I get the following error:
`Traceback (most recent call last):
File "/home/leo/anaconda2/bin/jupyter-notebook", line 7, in <module>
from notebook.notebookapp import main
File "/usr/lib/python3/dist-packages/notebook/notebookapp.py", line 31, in <module>
from zmq.eventloop import ioloop
File "/usr/lib/python3/dist-packages/zmq/__init__.py", line 34, in <module>
from zmq import backend
File "/usr/lib/python3/dist-packages/zmq/backend/__init__.py", line 40, in <module>
reraise(*exc_info)
File "/usr/lib/python3/dist-packages/zmq/backend/__init__.py", line 27, in <module>
_ns = select_backend(first)
File "/usr/lib/python3/dist-packages/zmq/backend/select.py", line 26, in select_backend
mod = __import__(name, fromlist=public_api)
File "/usr/lib/python3/dist-packages/zmq/backend/cython/__init__.py", line 6, in <module>
from . import (constants, error, message, context,
ImportError: cannot import name constants
Many of the solutions I've encountered required to uninstall and reinstall the pyzmq
package (via pip, conda, apt install; I've tried all of them). But that didn't work for me.
However, looking at the error I get, I think there's something wrong in the second line, precisely here: "/usr/lib/python3/dist-packages/notebook/notebookapp.py"
. It looks like there's some conflict among the two versions of Python I have.
I have Anaconda for Python 2.7 installed in my PC, but recently I had to install Spyder for Python 3.x. May it be the case that something got corrupted after the installation?
What I already tried:
- uninstall/reinstall pyzmq
- uninstall/reinstall jupyter
tried to run
jupyter kernelspec list
, but got a similar error (which leads me to think there's actually a conflict):Traceback (most recent call last): File "/home/leo/anaconda2/bin/jupyter-kernelspec", line 7, in <module> from jupyter_client.kernelspecapp import KernelSpecApp File "/usr/lib/python3/dist-packages/jupyter_client/__init__.py", line 4, in <module> from .connect import * File "/usr/lib/python3/dist-packages/jupyter_client/connect.py", line 22, in <module> import zmq File "/usr/lib/python3/dist-packages/zmq/__init__.py", line 34, in <module> from zmq import backend File "/usr/lib/python3/dist-packages/zmq/backend/__init__.py", line 40, in <module> reraise(*exc_info) File "/usr/lib/python3/dist-packages/zmq/backend/__init__.py", line 27, in <module> _ns = select_backend(first) File "/usr/lib/python3/dist-packages/zmq/backend/select.py", line 26, in select_backend mod = __import__(name, fromlist=public_api) File "/usr/lib/python3/dist-packages/zmq/backend/cython/__init__.py", line 6, in <module> from . import (constants, error, message, context, ImportError: cannot import name constants
EDIT:
I've run the command
pip3 uninstall jupyter
as Sangram Gaikwad suggested, so now I'm not using the wrong jupyter notebook anymore. However, if I try to execute jupyter-notebook
, now I get another error:
Traceback (most recent call last):
File "/home/leo/anaconda2/bin/jupyter-notebook", line 7, in <module>
from notebook.notebookapp import main
File "/home/leo/anaconda2/lib/python2.7/site-packages/notebook/__init__.py", line 25, in <module>
from .nbextensions import install_nbextension
File "/home/leo/anaconda2/lib/python2.7/site-packages/notebook/nbextensions.py", line 27, in <module>
from jupyter_core.utils import ensure_dir_exists
ImportError: cannot import name ensure_dir_exists
What I tried:
conda update jupyter_core jupyter_client
(it says they're already installed)conda uninstall jupyter notebook
, thenconda install jupyter notebook
(still get the same error)