15

So I tried to fix my Jupyter notebook (it wasn't letting me import libraries), however, it appears I made things worse. Now whenever I start the notebook, the kernel starts, and then instantly dies. The error I get is below:

[I 15:00:39.002 NotebookApp] Serving notebooks from local directory: /Users/stephanng/Documents/Coding/IPyNB
[I 15:00:39.002 NotebookApp] 0 active kernels 
[I 15:00:39.003 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/
[I 15:00:39.003 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 15:00:43.558 NotebookApp] Notebook 157 Muon Analysis - Copy.ipynb is not trusted
[I 15:00:44.045 NotebookApp] Kernel started: 152a55a1-e393-4e86-b271-859b924e6a3e
/Users/stephanng/anaconda/envs/py27/bin/python: No module named _signatures; 'ipykernel' is a package and cannot be directly executed
[I 15:00:47.047 NotebookApp] KernelRestarter: restarting kernel (1/5)
/Users/stephanng/anaconda/envs/py27/bin/python: No module named _signatures; 'ipykernel' is a package and cannot be directly executed
[I 15:00:50.059 NotebookApp] KernelRestarter: restarting kernel (2/5)
/Users/stephanng/anaconda/envs/py27/bin/python: No module named _signatures; 'ipykernel' is a package and cannot be directly executed
[I 15:00:53.067 NotebookApp] KernelRestarter: restarting kernel (3/5)
/Users/stephanng/anaconda/envs/py27/bin/python: No module named _signatures; 'ipykernel' is a package and cannot be directly executed
[W 15:00:54.257 NotebookApp] Timeout waiting for kernel_info reply from 152a55a1-e393-4e86-b271-859b924e6a3e
[I 15:00:56.078 NotebookApp] KernelRestarter: restarting kernel (4/5)
WARNING:root:kernel 152a55a1-e393-4e86-b271-859b924e6a3e restarted
/Users/stephanng/anaconda/envs/py27/bin/python: No module named _signatures; 'ipykernel' is a package and cannot be directly executed
[W 15:00:59.094 NotebookApp] KernelRestarter: restart failed
[W 15:00:59.095 NotebookApp] Kernel 152a55a1-e393-4e86-b271-859b924e6a3e died, removing from map.
ERROR:root:kernel 152a55a1-e393-4e86-b271-859b924e6a3e restarted failed!
[W 15:00:59.116 NotebookApp] Kernel deleted before session
[W 15:00:59.117 NotebookApp] 410 DELETE /api/sessions/15eb80b6-d134-4142-96fa-1b1012be280c (::1) 5.42ms referer=http://localhost:8888/notebooks/157%20Muon%20Analysis%20-%20Copy.ipynb

Is there a way to fix this? Or should I just go about a full uninstall and reinstall? Also, how do I go about doing so? When I do sudo pip uninstall jupyter, it doesn't seem to work.

Antimony
  • 2,230
  • 3
  • 28
  • 38
Stephan Ng
  • 311
  • 1
  • 2
  • 5
  • It is `pip uninstall jupyter-core jupyter-client notebook`, but yeah, still bad idea unless you are in a virtualenv – OneCricketeer Feb 04 '16 at 23:51
  • Did you do something special to your notebook? `.ipynb is not trusted` means it was digitally signed somehow – OneCricketeer Feb 04 '16 at 23:54
  • 2
    I actually believe that I got it to work. I uninstalled (basically everything) including conda (by rm -rf) and then I reinstalled conda and jupyter. It seems to have worked for python2 notebooks – Stephan Ng Feb 05 '16 at 00:20
  • 1
    I would delete the kernel and re install it. Refer to this here https://stackoverflow.com/a/42647666/7359507 – Yusuf Dec 27 '17 at 03:48
  • Have you tried this - pip install "ipython[notebook]" --upgrade – Reck Feb 25 '18 at 18:42

3 Answers3

1

This is a FAQ.

tl;dr: Do this within your notebook if you need e.g. numpy:

import sys
!conda install --yes --prefix {sys.prefix} numpy

Please refer to http://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/ for a detailed discussion of why "import foo" in a Jupyter environment differs from "import foo" in a command line environment.

J_H
  • 17,926
  • 4
  • 24
  • 44
0

After activating the conda environment run this command:

python -m ipykernel install --user

Paul
  • 1,801
  • 1
  • 12
  • 18
0

try doing this in you terminal

pip install -U numpy

Raj Singh
  • 1
  • 1