macOS 上 Python 3.7 的 Anaconda 2019.03 上的 Jupyter Notebook 中的内核错误

Dat*_*ars 2 macos python-3.x anaconda jupyter-notebook

我刚刚使用 Python 3.7 为 macOS 安装了 Anaconda 2019.03,并希望将其用于使用 Jupyter Notebook 进行 Python 3 编程。当我运行 Jupyter Notebook 时,由于内核错误,没有任何效果。

我在重新安装之前已经卸载了Python 2.7和Python 3.7的Anaconda(因为一个单独的问题,我卸载并重新安装了它),并且我认为在我手动卸载Anaconda时可能已经删除了一些重要的内核文件。我认为下面的错误消息表明 Anaconda 是从一个名为anaconda3root ( /)内部的文件夹启动的,但在错误消息的最后一行,它似乎在我的主文件夹 ( myhomefolder) 中寻找某些东西。我不太确定如何解释这一点,因为我对此还很陌生。

Traceback (most recent call last):
  File "/anaconda3/lib/python3.7/site-packages/tornado/web.py", line 1699, in _execute
    result = await result
  File "/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 736, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "/anaconda3/lib/python3.7/site-packages/notebook/services/sessions/handlers.py", line 73, in post
    type=mtype))
  File "/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 729, in run
    value = future.result()
  File "/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 736, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "/anaconda3/lib/python3.7/site-packages/notebook/services/sessions/sessionmanager.py", line 79, in create_session
    kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
  File "/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 729, in run
    value = future.result()
  File "/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 736, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "/anaconda3/lib/python3.7/site-packages/notebook/services/sessions/sessionmanager.py", line 92, in start_kernel_for_session
    self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
  File "/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 729, in run
    value = future.result()
  File "/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 209, in wrapper
    yielded = next(result)
  File "/anaconda3/lib/python3.7/site-packages/notebook/services/kernels/kernelmanager.py", line 160, in start_kernel
    super(MappingKernelManager, self).start_kernel(**kwargs)
  File "/anaconda3/lib/python3.7/site-packages/jupyter_client/multikernelmanager.py", line 110, in start_kernel
    km.start_kernel(**kwargs)
  File "/anaconda3/lib/python3.7/site-packages/jupyter_client/manager.py", line 259, in start_kernel
    **kw)
  File "/anaconda3/lib/python3.7/site-packages/jupyter_client/manager.py", line 204, in _launch_kernel
    return launch_kernel(kernel_cmd, **kw)
  File "/anaconda3/lib/python3.7/site-packages/jupyter_client/launcher.py", line 138, in launch_kernel
    proc = Popen(cmd, **kwargs)
  File "/anaconda3/lib/python3.7/subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "/anaconda3/lib/python3.7/subprocess.py", line 1522, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/myhomefolder/anaconda/envs/ipykernel_py3/bin/python': '/Users/myhomefolder/anaconda/envs/ipykernel_py3/bin/python'
Run Code Online (Sandbox Code Playgroud)

Dat*_*ars 8

解决方案是在终端中运行以下命令:

python -m ipykernel install --user,

我相信它安装了内核。我在以下 GitHub 帖子中找到了解决方案,启动 jupyter 我得到内核错误 #2301

我不知道这是否是将来避免类似问题的最完整的解决方案,但它现在似乎有效。如果有人有其他建议,我当然很高兴听到这些建议。