【问题标题】:Jupyter Notebook, - failed to start the kernel, on new installJupyter Notebook, - 无法启动内核,在新安装时
【发布时间】:2020-05-25 12:33:07
【问题描述】:

我一直在尝试设置一个新的 macbook jupyter notebook 环境。我是这里的新手。我读到最好的方法是使用 pyenv,经过多次试验和错误,我放弃了它,但并非没有大量安装和卸载。让一切都指向正确的地方是我无法做到的。

我想回到我所知道的基础 anaconda 安装。我已经清理并重新安装了 anaconda3。我可以从终端启动 jupyter 笔记本。但是我得到一个内核错误,

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'
******

我的 Jupyter 路径是

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

我正在以一种不专心的方式打滚,并且花了很多时间安装和拆卸,但可以在有能力的人的帮助下完成!

如果我尝试安装内核python3 -m pip install ipykernel,我会得到它已经安装的响应。

有什么东西指向旧内核吗? 干杯

编辑。 我尝试使用 pip-autoremove jupyter -y 删除 jupyter 输出,

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

这没有意义,- 应用程序怎么找不到和要求它?

【问题讨论】:

  • 我用的是linux,不过好像在mac上应该是一样的。您是否尝试过只输入conda create --name myenvname,然后输入conda install jupyter-lab
  • 是的,当我尝试打开旧的 jupyter 笔记本或创建新的笔记本时,我得到了相同的内核错误。
  • 它不能在 conda enviromnet 上运行吗?所以你创建它和conda activate myenvname。想法是您完全在 anaconda 基础架构中工作,而不是虚拟环境。
  • 否,使用 anaconda 创建了一个新环境,并在该环境中创建了一个新笔记本。同样的错误。

标签: python python-3.x jupyter-notebook anaconda


【解决方案1】:

从系统中删除所有jupyter版本,从anaconda创建一个虚拟环境(conda create等),激活这个环境,然后从这里安装jupyter

【讨论】:

    【解决方案2】:

    已通过this 链接解决。本质上,我在尝试使用 pyenv 的过程中已经创建了一个环境,并且还有对它的剩余引用。我用过

    python -m ipykernel install --user
    

    创建一个新内核。 感谢那些帮助过的人。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-29
      • 2022-11-02
      • 1970-01-01
      • 2021-02-26
      • 1970-01-01
      • 2021-02-13
      • 1970-01-01
      • 2021-02-12
      相关资源
      最近更新 更多