Homebrew 安装的 Anaconda 中的 JupyterLab 无法启动内核,寻找旧安装

JupyterLab in Homebrew-installed Anaconda fails to start kernel, looks for old install

我希望有人能帮助我理解为什么 JupyterLab 无法在我的系统上启动内核。

背景

我正在使用 macOS High Sierra。我曾经通过 Mac OS 安装程序在我的主文件夹 ($HOME/anaconda) 的默认位置安装 Anaconda。基于 我卸载了 Anaconda。

我从 Homebrew Cask 重新安装了 Anaconda(将 export PATH=/usr/local/anaconda3/bin:"$PATH" 放入我的 .bashrc)。

问题

现在当我

进程失败,输出如下:

Traceback (most recent call last): File "/usr/local/anaconda3/lib/python3.6/site-packages/tornado/web.py", line 1543, in _execute result = yield result File "/usr/local/anaconda3/lib/python3.6/site-packages/tornado/gen.py", line 1099, in run value = future.result() File "/usr/local/anaconda3/lib/python3.6/site-packages/tornado/gen.py", line 1107, in run yielded = self.gen.throw(*exc_info) File "/usr/local/anaconda3/lib/python3.6/site-packages/notebook/services/sessions/handlers.py", line 73, in post type=mtype)) File "/usr/local/anaconda3/lib/python3.6/site-packages/tornado/gen.py", line 1099, in run value = future.result() File "/usr/local/anaconda3/lib/python3.6/site-packages/tornado/gen.py", line 1107, in run yielded = self.gen.throw(*exc_info) File "/usr/local/anaconda3/lib/python3.6/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 "/usr/local/anaconda3/lib/python3.6/site-packages/tornado/gen.py", line 1099, in run value = future.result() File "/usr/local/anaconda3/lib/python3.6/site-packages/tornado/gen.py", line 1107, in run yielded = self.gen.throw(*exc_info) File "/usr/local/anaconda3/lib/python3.6/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 "/usr/local/anaconda3/lib/python3.6/site-packages/tornado/gen.py", line 1099, in run value = future.result() File "/usr/local/anaconda3/lib/python3.6/site-packages/tornado/gen.py", line 315, in wrapper yielded = next(result) File "/usr/local/anaconda3/lib/python3.6/site-packages/notebook/services/kernels/kernelmanager.py", line 148, in start_kernel super(MappingKernelManager, self).start_kernel(**kwargs) File "/usr/local/anaconda3/lib/python3.6/site-packages/jupyter_client/multikernelmanager.py", line 110, in start_kernel km.start_kernel(**kwargs) File "/usr/local/anaconda3/lib/python3.6/site-packages/jupyter_client/manager.py", line 259, in start_kernel **kw) File "/usr/local/anaconda3/lib/python3.6/site-packages/jupyter_client/manager.py", line 204, in _launch_kernel return launch_kernel(kernel_cmd, **kw) File "/usr/local/anaconda3/lib/python3.6/site-packages/jupyter_client/launcher.py", line 128, in launch_kernel proc = Popen(cmd, **kwargs) File "/usr/local/anaconda3/lib/python3.6/subprocess.py", line 709, in __init__ restore_signals, start_new_session) File "/usr/local/anaconda3/lib/python3.6/subprocess.py", line 1344, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: '~/anaconda/bin/python': '~/anaconda/bin/python'

我已经从我的环境(.bashrc.bash_profile)中删除了对 $HOME/anaconda(我的旧安装位置)的所有引用,所以我不知道在哪里正在收集参考资料。

如有任何建议,我们将不胜感激。

此问题已在 this GitHub thread 中针对 Jupyter 项目得到解答。基本解决方案:

  • 运行 jupyter kernelspec list 查看是否指向正确的 Python 安装
    • 如果没有,删除文件夹~/Library/Jupyter
    • 重新运行jupyter kernelspec list

这应该重建目录并给出类似

的输出

Available kernels: python3 /usr/local/anaconda3/share/jupyter/kernels/python3

这是 Homebrew 安装 Anaconda 的正确位置。