notebook: unable to start Jupyter notebook

Hi, I’m not able to launch the jupyter notebook:

Traceback (most recent call last):
  File "/usr/local/bin/jupyter-notebook", line 7, in <module>
    from notebook.notebookapp import main
  File "/usr/local/lib/python2.7/dist-packages/notebook/notebookapp.py", line 32, in <module>
    from zmq.eventloop import ioloop
  File "/usr/local/lib/python2.7/dist-packages/zmq/__init__.py", line 66, in <module>
    from zmq import backend
  File "/usr/local/lib/python2.7/dist-packages/zmq/backend/__init__.py", line 41, in <module>
    reraise(*exc_info)
  File "/usr/local/lib/python2.7/dist-packages/zmq/utils/sixcerpt.py", line 34, in reraise
    raise value
  File "/usr/local/lib/python2.7/dist-packages/zmq/backend/__init__.py", line 29, in <module>
    _ns = select_backend(first)
Traceback (most recent call last):
  File "/usr/local/bin/jupyter-notebook", line 7, in <module>
    from notebook.notebookapp import main
  File "/usr/local/lib/python2.7/dist-packages/notebook/notebookapp.py", line 32, in <module>
    from zmq.eventloop import ioloop
  File "/usr/local/lib/python2.7/dist-packages/zmq/__init__.py", line 66, in <module>
    from zmq import backend
  File "/usr/local/lib/python2.7/dist-packages/zmq/backend/__init__.py", line 41, in <module>
    reraise(*exc_info)
  File "/usr/local/lib/python2.7/dist-packages/zmq/utils/sixcerpt.py", line 34, in reraise
    raise value
  File "/usr/local/lib/python2.7/dist-packages/zmq/backend/__init__.py", line 29, in <module>
    _ns = select_backend(first)
  File "/usr/local/lib/python2.7/dist-packages/zmq/backend/select.py", line 27, in select_backend
    mod = __import__(name, fromlist=public_api)
  File "/usr/local/lib/python2.7/dist-packages/zmq/backend/cython/__init__.py", line 6, in <module>
    from . import (constants, error, message, context,
ImportError: /usr/local/lib/python2.7/dist-packages/zmq/backend/cython/constants.so: undefined symbol: PyUnicodeUCS4_DecodeUTF8

It was working a few months ago. I just upgraded it.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 7
  • Comments: 34 (9 by maintainers)

Most upvoted comments

Try uninstalling and reinstalling pyzmq.

This works for me jupyter notebook --generate-config

  • Windows10(64bit)
  • Anaconda pip uninstall jupyter pip install jupyter pip install --force-reinstall --upgrade pyzmq

Success. Thank you!

Okay, I just spent two hours trying to fix this annoying issue. I built zeromq from source and it tells me something about libsodium so I installed that. Then, zeromq built succesfully. Great. Then, I fire up my jupyter notebook and still same message.

Then, I commented out: export PYTHONPATH=/usr/local/lib/python2.7/dist packages:$PYTHONPATH and I get the following message:

The Jupyter HTML Notebook.

This launches a Tornado based HTML Notebook Server that serves up an
HTML5/Javascript Notebook client.

Subcommands
-----------

Subcommands are launched as `jupyter-notebook cmd [args]`. For information on
using subcommand 'cmd', do: `jupyter-notebook cmd -h`.

list
    List currently running notebook servers in this profile.

Options
-------

Arguments that take values are actually convenience aliases to full
Configurables, whose aliases are listed on the help line. For more information
on full configurables, see '--help-all'.

-y
    Answer yes to any questions instead of prompting.
--pylab
    DISABLED: use %pylab or %matplotlib in the notebook to enable matplotlib.
--no-browser
    Don't open the notebook in a browser after startup.
--no-script
    DEPRECATED, IGNORED
--debug
    set log level to logging.DEBUG (maximize logging output)
--script
    DEPRECATED, IGNORED
--generate-config
    generate default config file
--no-mathjax
    Disable MathJax

    MathJax is the javascript library IPython uses to render math/LaTeX. It is
    very large, so you may want to disable it if you have a slow internet
    connection, or for offline use of the notebook.

    When disabled, equations etc. will appear as their untransformed TeX source.
--port-retries=<Int> (NotebookApp.port_retries)
    Default: 50
    The number of additional ports to try if the specified port is not
    available.
--certfile=<Unicode> (NotebookApp.certfile)
    Default: ''
    The full path to an SSL/TLS certificate file.
--pylab=<Unicode> (NotebookApp.pylab)
    Default: 'disabled'
    DISABLED: use %pylab or %matplotlib in the notebook to enable matplotlib.
--ip=<Unicode> (NotebookApp.ip)
    Default: 'localhost'
    The IP address the notebook server will listen on.
--config=<Unicode> (JupyterApp.config_file)
    Default: ''
    Full path of a config file.
--log-level=<Enum> (Application.log_level)
    Default: 30
    Choices: (0, 10, 20, 30, 40, 50, 'DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL')
    Set the log level by value or name.
--browser=<Unicode> (NotebookApp.browser)
    Default: ''
    Specify what command to use to invoke a web browser when opening the
    notebook. If not specified, the default browser will be determined by the
    `webbrowser` standard library module, which allows setting of the BROWSER
    environment variable to override it.
--notebook-dir=<Unicode> (NotebookApp.notebook_dir)
    Default: ''
    The directory to use for notebooks and kernels.
--transport=<CaselessStrEnum> (KernelManager.transport)
    Default: 'tcp'
    Choices: ['tcp', 'ipc']
--keyfile=<Unicode> (NotebookApp.keyfile)
    Default: ''
    The full path to a private key file for usage with SSL/TLS.
--port=<Int> (NotebookApp.port)
    Default: 8888
    The port the notebook server will listen on.

To see all available configurables, use `--help-all`

Examples
--------

    ipython notebook                       # start the notebook
    ipython notebook --profile=sympy       # use the sympy profile
    ipython notebook --certfile=mycert.pem # use SSL/TLS certificate

[C 21:53:35.843 NotebookApp] Bad config encountered during initialization:
[C 21:53:35.843 NotebookApp] The 'contents_manager_class' trait of <notebook.notebookapp.NotebookApp object at 0x7fca5ad369b0> instance must be a type, but 'ipymd.IPymdContentsManager' could not be imported

By this time, I am just done with this so decide to use anaconda for python 3. And, I get the same message as posted above! If anaconda is supposed to be isolated environment and it installed successfully and path was set to it then I would expect it to work. Now, I will go back to my distro. Note that I have both Python 2 and 3. What info do you need?

That looks like jupyter_environment_kernels is partly installed. If you need help working it out, post an issue there.

Solution:

conda create -n py35 python=3.5 anaconda

I simply create a new environment using the full anaconda metapackage. And it works.

Thanks for the reply! I may have worded not clearly enough: I CANNOT use Anaconda, as it’s not available on the Jetson. I edited the message above to be clearer.

Tried sudo pip3 install --force-reinstall --upgrade pyzmq to no avail. Though forcing still getting Not uninstalling pyzmq at /usr/lib/python3/dist-packages, outside environment /usr

Well if you are using anaconda. Then open the Anaconda Navigator and then just update the Jupyter notebook app. It worked for me. After all the hassle of trying to solve just a simple app update worked on Anaconda. If that still doesn’t work then try reinstalling.

uninstall pyzmq and then reinstall using wheel file from here works for me.

Hi, I am having troubles with the same problem:

Traceback (most recent call last): File “/Library/Frameworks/Python.framework/Versions/3.5/bin/jupyter-notebook”, line 7, in <module> from notebook.notebookapp import main File “/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/notebook/notebookapp.py”, line 31, in <module> from zmq.eventloop import ioloop File “/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/zmq/init.py”, line 34, in <module> from zmq import backend File “/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/zmq/backend/init.py”, line 40, in <module> reraise(*exc_info) File “/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/zmq/utils/sixcerpt.py”, line 34, in reraise raise value File “/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/zmq/backend/init.py”, line 27, in <module> _ns = select_backend(first) File “/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/zmq/backend/select.py”, line 27, in select_backend mod = import(name, fromlist=public_api) File “/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/zmq/backend/cython/init.py”, line 6, in <module> from . import (constants, error, message, context, ImportError: cannot import name ‘constants’

Ok, let’s try to do things stem by step, I include what I get for information. If you get something too different or are unsure, ask at the specific step and we can go into more details.

List all kernels:

$ jupyter kernelspec list
Available kernels:
  haskell      ~/Library/Jupyter/kernels/haskell
  julia-0.3    ~/Library/Jupyter/kernels/julia-0.3
  julia-0.4    ~/Library/Jupyter/kernels/julia-0.4
  julia-0.5    ~/Library/Jupyter/kernels/julia-0.5
  py34         /usr/local/share/jupyter/kernels/py34
  python2      /usr/local/share/jupyter/kernels/python2
  python3      /usr/local/share/jupyter/kernels/python3

you can remove the folders of the kernels you do not want.

Find which python jupyter uses:

$ head -n1 $(which jupyter)
#!~/anaconda3/bin/python3

This is the python that have ZMQ installed.

Find which python IPython uses"

$ head -n1 $(which ipython)
#!~/anaconda3/bin/python3

Check that the above python we just got does indeed have ZMQ:

$ ~/anaconda3/bin/python3 -c 'import zmq'
# Should not complain, if there is ZMQ or print the following if it does not have:
# Traceback (most recent call last):
#  File "<string>", line 1, in <module>
# ImportError: No module named 'zmq'

If we have ZMQ try to install the kernel with this particuart python and give it a specific name just to find it easily

$ ~/anaconda3/bin/python3 -m IPython kernel install --name 'zmqpython' --display-name 'ZMQ Python'

It should appear in the kernel list:

$ jupyter kernelspec list
Available kernels:
  haskell      ~/Library/Jupyter/kernels/haskell
  julia-0.3    ~/Library/Jupyter/kernels/julia-0.3
  julia-0.4    ~/Library/Jupyter/kernels/julia-0.4
  julia-0.5    ~/Library/Jupyter/kernels/julia-0.5
  py34         /usr/local/share/jupyter/kernels/py34
  python2      /usr/local/share/jupyter/kernels/python2
  python3      /usr/local/share/jupyter/kernels/python3
  zmqpython    /usr/local/share/jupyter/kernels/zmqpython

And in the new dropdown menu in the notebook.

Oh, you seem to be in a weird corner case/ have bad luck:

I see in one message that you are missing one package that you probably configured manually (ipymd), check in your config if you have c.NotebookApp.contents_manager_class = 'ipymd.IPymdContentsManager', if so comment it, we can reinstall it later and retry. The part of the error:

[C 21:53:35.843 NotebookApp] The 'contents_manager_class' trait of <notebook.notebookapp.NotebookApp object at 0x7fca5ad369b0> instance must be a type, but 'ipymd.IPymdContentsManager' could not be imported

Like ly the config file will be in ~/.jupyter/jupyter_notebook_config.py (you can check with jupyter --config-dir)

And, I get the same message as posted above! If anaconda is supposed to be isolated environment and it installed successfully and path was set to it then I would expect it to work.

The only difference is that the Jupyter/IPython config is global, so if you have a issue in your config this might happen. This is needed as users might want to run only on server with various conda env

Anaconda will also only provide isolation if you are using bash, and don’t mess with $PATH in a way that anaconda can’t prevent. Typically it needs to shell-out to some external programs. And if $PATH is not correct, it can’t know.

Anyway, if it works by commenting the config, we can try to reinstall ipymd in the right environment to get you set up again.

Sorry for the trouble you are encountering.