简体   繁体   中英

Jupyter Notebook, - failed to start the kernel, on new install

I have been trying to set up a new macbook jupyter notebook environment. I am a novice here. I read the best way to do this was with pyenv and after much trial and error I have given that up, tho not without much installs and uninstalls. It is beyond me at the mo to get everything pointing at the right place.

I wanted to go back to what I know which is the base anaconda install. I have cleaned and reinstalled anaconda3. I can launch jupyter notebooks from the terminal. However i am getting a kernel error,

Traceback (most recent call last):
  File "/Users/******/anaconda3/lib/python3.7/site-packages/tornado/web.py", line 1699, in _execute
    result = await result
  File "/Users/******/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "/Users/******/anaconda3/lib/python3.7/site-packages/notebook/services/sessions/handlers.py", line 72, in post
    type=mtype))
  File "/Users/******/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 735, in run
    value = future.result()
  File "/Users/******/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "/Users/******/anaconda3/lib/python3.7/site-packages/notebook/services/sessions/sessionmanager.py", line 88, in create_session
    kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
  File "/Users/******/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 735, in run
    value = future.result()
  File "/Users/******/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "/Users/******/anaconda3/lib/python3.7/site-packages/notebook/services/sessions/sessionmanager.py", line 101, in start_kernel_for_session
    self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
  File "/Users/******/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 735, in run
    value = future.result()
  File "/Users/******/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 209, in wrapper
    yielded = next(result)
  File "/Users/******/anaconda3/lib/python3.7/site-packages/notebook/services/kernels/kernelmanager.py", line 168, in start_kernel
    super(MappingKernelManager, self).start_kernel(**kwargs)
  File "/Users/******/anaconda3/lib/python3.7/site-packages/jupyter_client/multikernelmanager.py", line 110, in start_kernel
    km.start_kernel(**kwargs)
  File "/Users/******/anaconda3/lib/python3.7/site-packages/jupyter_client/manager.py", line 259, in start_kernel
    **kw)
  File "/Users/******/anaconda3/lib/python3.7/site-packages/jupyter_client/manager.py", line 204, in _launch_kernel
    return launch_kernel(kernel_cmd, **kw)
  File "/Users/******/anaconda3/lib/python3.7/site-packages/jupyter_client/launcher.py", line 138, in launch_kernel
    proc = Popen(cmd, **kwargs)
  File "/Users/******/anaconda3/lib/python3.7/subprocess.py", line 800, in __init__
    restore_signals, start_new_session)
  File "/Users/******/anaconda3/lib/python3.7/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/******/.pyenv/versions/jupyter3/bin/python': '/Users/******/.pyenv/versions/jupyter3/bin/python'
******

My Jupyter paths is

config:
    /Users/****/.jupyter
    /Users/****/anaconda3/etc/jupyter
    /usr/local/etc/jupyter
    /etc/jupyter
data:
    /Users/****/Library/Jupyter
    /Users/****/anaconda3/share/jupyter
    /usr/local/share/jupyter
    /usr/share/jupyter
runtime:
    /Users/****/Library/Jupyter/runtime

I am wallowing around in an unfocussed way and having spent a lot of time installing and removing could do with some focussed help from someone who can..

If I try installing the kernel python3 -m pip install ipykernel I get the response that it is already installed.

Could something be pointing at an old kernel? Cheers

Edit. I tried to remove jupyter using pip-autoremove jupyter -y output,

pip-autoremove jupyter -y                                                                                         ─╯
Traceback (most recent call last):
  File "/usr/local/bin/pip-autoremove", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/pip_autoremove.py", line 106, in main
    autoremove(args, yes=opts.yes)
  File "/usr/local/lib/python3.7/site-packages/pip_autoremove.py", line 21, in autoremove
    dead = list_dead(names)
  File "/usr/local/lib/python3.7/site-packages/pip_autoremove.py", line 28, in list_dead
    start = set(map(get_distribution, names))
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 482, in get_distribution
    dist = get_provider(dist)
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 358, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 901, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 787, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'jupyter' distribution was not found and is required by the application

which makes no sense, - how can it be not found and required by the applciation?

Remove all jupyter versions from the system, create a virtual environment from anaconda (conda create etc.), activate this env., and from here install jupyter

Solved by this link. Essentially I had made an environmenmt during my attempts with pyenv and there were residual references to it. I used

python -m ipykernel install --user

to create a new kernel. Thanks to those guys who helped.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM