Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to start Jupyter notebook #636

Closed
codebeetle opened this issue Oct 21, 2015 · 34 comments
Closed

unable to start Jupyter notebook #636

codebeetle opened this issue Oct 21, 2015 · 34 comments

Comments

@codebeetle
Copy link

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.

@Carreau
Copy link
Member

Carreau commented Oct 21, 2015

Seem to be a problem with zmq.

Have you tried to reinstall it ? Have you try updating python to a more recent version like 3.4 or 3.5 ?

@codebeetle
Copy link
Author

I don't know. I tried updating zmq and pyzmq and friends both thru pkg mgr and pip. Everything was working fine few months ago. Jupyter(via zmq) is not working but hadn't used it in a while so maybe some unrelated software install in the meanwhile changed something with zmq? Who knows but I will try re-installing from scratch.

@codebeetle
Copy link
Author

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?

@Carreau
Copy link
Member

Carreau commented Oct 23, 2015

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.

@codebeetle
Copy link
Author

That worked, thanks for your help with debugging. Now, I can start Jupyter Notebook. But immediately upon creating a new notebook, the kernel dies for all my language kernels including Python 2, 3, and my three other language kernels. Here is some output. Any idea?

[I 12:27:21.863 NotebookApp] KernelRestarter: restarting kernel (3/5)
/usr/local/lib/python2.7/dist-packages/IPython/kernel/init.py:13: ShimWarning: The IPython.kernel package has been deprecated. You should import from ipykernel or jupyter_client instead.
"You should import from ipykernel or jupyter_client instead.", ShimWarning)
/usr/bin/python: libzmq.so.3: cannot open shared object file: No such file or directory; 'IPython.kernel' is a package and cannot be directly executed
[W 12:27:23.379 NotebookApp] Timeout waiting for kernel_info reply from bbbeb806-3642-4d2f-b6da-975bc94f05bf
[I 12:27:23.469 NotebookApp] Kernel started: 41e6846b-3710-430d-8b29-0db474b27b0c
/usr/local/lib/python3.4/dist-packages/IPython/kernel/init.py:13: ShimWarning: The IPython.kernel package has been deprecated. You should import from ipykernel or jupyter_client instead.
"You should import from ipykernel or jupyter_client instead.", ShimWarning)
/usr/bin/python3: Error while finding spec for 'IPython.kernel.main' (<class 'ImportError'>: libzmq.so.3: cannot open shared object file: No such file or directory); 'IPython.kernel' is a package and cannot be directly executed

@Carreau
Copy link
Member

Carreau commented Oct 24, 2015

That's because your system still find old kernels from a non-working IPython env.

Try ipython kernel install for each python you want to a kernel for.

At some point I would also suggest trying to find the non working installation of IPython/lib zmq and remove them.

@Carreau
Copy link
Member

Carreau commented Oct 24, 2015

(if you want to be even more sure, you can do python -m IPython kernel install when python is the link to the right python)

@codebeetle
Copy link
Author

That does not work, it complains about not finding zmq. I did that using kernelspec command when I initially upgraded to Jupyter when it was first released. I have a bunch of language kernels listed in my menu. I do not have any idea where to locate the old kernels non working IPython or zmq. Perhaps, that could be built in to the upgrade process. I have other programs that are recognizing my Python 3 interpreter but not IPython or Jupyter. When I have time to play around with this again, I'll get in touch. Mark this as unresolved.

@willingc
Copy link
Member

@Carreau @minrk Please tag "pending additional information" from @codebeetle.

@willingc
Copy link
Member

Nevermind ^^ Already labeled "needs info".

@Carreau
Copy link
Member

Carreau commented Oct 26, 2015

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.

@codebeetle
Copy link
Author

Jupyter with zmq problem. Not fully working. Updates should be improved.

@minrk minrk added this to the no action milestone Dec 14, 2015
@Diego-MX
Copy link

Diego-MX commented Jul 18, 2016

I am having an issue that is similar to this one, probably even the same one... although I haven't gotten as far with zmq.
I'm on Ubuntu 16.04 and installed Jupyter through Anaconda. The error I'm getting on running many jupyter commands is:

~/.local/lib/python3.4/site-packages/zmq/backend/cffi/__pycache__/_cffi_ext.c:212:17:   
fatal error: zmq.h: No such file or directory
compilation terminated.
Traceback (most recent call last):
...
ImportError: libzmq.so.3: cannot open shared object file: No such file or directory

So I tried updating libzmq3-dev with apt-get and also with pip and conda, but none have proven successful. I noticed codebeetle built it from source, and I was hoping I didn't need to do that.

Thank you in advance, and let me know if I can give you more details.

@takluyver
Copy link
Member

Try uninstalling and reinstalling pyzmq.

@a1209910
Copy link

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
from notebook.notebookapp import main
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/notebook/notebookapp.py", line 31, in
from zmq.eventloop import ioloop
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/zmq/init.py", line 34, in
from zmq import backend
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/zmq/backend/init.py", line 40, in
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
_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
from . import (constants, error, message, context,
ImportError: cannot import name 'constants'

@Yumin-Sun-00
Copy link

I have same problem. And I did twice pyzmq installation. But it does not work.

@Yumin-Sun-00
Copy link

Solution:

conda create -n py35 python=3.5 anaconda

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

@ikrambennasrbennasr
Copy link

Hello, please when i run jupyter notebook in ubuntu aws i get this problem ! Thanks
notebook

@takluyver
Copy link
Member

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

@ikrambennasrbennasr
Copy link

@takluyver thanks for the answer, it runs :)

@Gabriel-p
Copy link

Thank you @waschbaer00! Your solution was the only one that worked for me.

@nataliele
Copy link

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

@ai-bits
Copy link

ai-bits commented Jul 16, 2018

On a Jetson TX2 with Ubuntu 16.04 on ARM64 this is all very complicated.
I installed the allegedly missing libzmq according to
https://gist.github.com/katopz/8b766a5cb0ca96c816658e9407e83d00
and then jupyter installed, BUT now I get the error referenced here and when I try to
sudo pip3 uninstall pyzmq
I get
Not uninstalling pyzmq at /usr/lib/python3/dist-packages, outside environment /usr

I´m using JetPack 3.2's Python3 and CANNOT use Anaconda (that I got somewhat used to - unavailable on the Jetson) and still trying to get the hang of sudo -H or --user.
Thanks for any help!
G.

@Aashu770
Copy link

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.

@ai-bits
Copy link

ai-bits commented Jul 17, 2018

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

@ai-bits
Copy link

ai-bits commented Jul 17, 2018

Success!
sudo pip3 uninstall jupyter #the erring install
I followed
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-jupyter-notebook-to-run-ipython-on-ubuntu-16-04
sudo apt-get update
#sudo apt-get -y install python-pip python-dev #pip and dev already installed for 2 and 3
sudo apt-get -y install ipython ipython-notebook
sudo -H pip install jupyter

AFAI understand this Jupyter runs on 2.7 now as I overlooked to change pip to pip3, but it works and I don´t care as long as Jupyter allows for New Python3 notebooks.

PS: Just came across sudo nano /usr/local/bin/ipython and added a '3' to #!/usr/bin/python, but I don't know how to check the basis.

PPS: which ipython3 says /usr/bin/ipython3, so I tried
sudo apt-get -y install ipython3 ipython3-notebook #mind the 3!
which thankfully revived the Spyder3 iPython console that had been brought down with the zmq fiddling.

Why apt for ipython and not pip or pip3, why dependencies are not auto-installed,... is beyond me.

It may have been advisable to use venv (or virtualenv?, sadly no Anaconda on Jetson) and specify the Python major version, but a nasty pip 8 to 10 bug cost me another bunch of hours and threw me off the path.

@mburke05
Copy link

after manually upgrading my conda environment to 3.6, i got this error. ai-bits suggestion to forcefully pip reinstall pyzmq worked perfectly, thanks!

@argenisleon
Copy link

This works for me jupyter notebook --generate-config

@feldon0606
Copy link

Try uninstalling and reinstalling pyzmq.

fantastic! Worked for me!

@aokit
Copy link

aokit commented Nov 4, 2018

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

Success. Thank you!

@eyildiz-ugoe
Copy link

eyildiz-ugoe commented Dec 21, 2018

None of the above worked for me. No Anaconda is there either. Strange.

Edit: May sound silly, but a newer version of the notebook uses jupyter-notebook command, whereas the old one does not have a dash inbetween. Once I launched with the dash, it worked.

@caseyjconger
Copy link

caseyjconger commented Jan 16, 2019

I was getting this error and what seemed to be the issue was that I did not reinstall jupyter in my new environment, so it was running jupyter from my system installation. So, all it took as activating my environment and installing jupyter:

$ pyenv activate my_env
(my_env) $ pip install jupyter

@phdsky
Copy link

phdsky commented Mar 7, 2019

This works for me jupyter notebook --generate-config

Thanks, worked

@disarticulate
Copy link

disarticulate commented Feb 27, 2020

Am sure there's alot of technical reasons. I found one, I had a random roaming python installed somewhere in Windows 10.

>>> import sys
>>> for p in sys.path:
...     print(p)
...
C:\Users\gis\AppData\Local\Continuum\anaconda3\python37.zip
C:\Users\gis\AppData\Local\Continuum\anaconda3\DLLs
C:\Users\gis\AppData\Local\Continuum\anaconda3\lib
C:\Users\gis\AppData\Local\Continuum\anaconda3
C:\Users\gis\AppData\Roaming\Python\Python37\site-packages
C:\Users\gis\AppData\Local\Continuum\anaconda3\lib\site-packages
C:\Users\gis\AppData\Local\Continuum\anaconda3\lib\site-packages\win32
C:\Users\gis\AppData\Local\Continuum\anaconda3\lib\site-packages\win32\lib
C:\Users\gis\AppData\Local\Continuum\anaconda3\lib\site-packages\Pythonwin

The site packages for this aberrant python37 were taking precendent. Everything worked when booting from a cmd.exe, but when I tried to run something like nbopen.exe, i'd get the "sys/un.h" not found.

Solution was to delete the empty roaming python folders.

del C:\Users\gis\AppData\Roaming\Python

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests