Search code examples
anacondajupyter-notebookjupyter-labhomebrew-cask

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


I was hoping someone could help me understand why JupyterLab fails to spin up a kernel on my system.

Background

I'm working on macOS High Sierra. I used to have Anaconda installed via the Mac OS installer in the default location in my home folder ($HOME/anaconda). Based on this thread I uninstalled Anaconda.

I reinstalled Anaconda from the Homebrew Cask (placing export PATH=/usr/local/anaconda3/bin:"$PATH" in my .bashrc).

The Problem

Now when I

  • run jupyter-lab,
  • create a new notebook, and
  • select a Python 3 kernel,

the process fails with the following output:

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'

I'd already removed all references to $HOME/anaconda (my old install location) from my environment (.bashrc, .bash_profile), so I can't figure out where the reference is being picked up.

Any suggestions would be greatly appreciated.


Solution

  • This question was answered in this GitHub thread for the Jupyter project. The basic solution:

    • run jupyter kernelspec list to see if it points to the correct Python install
      • if not, remove the folder ~/Library/Jupyter
      • re-run jupyter kernelspec list

    This should rebuild the directory and give output like

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

    which is the proper location for the Homebrew install of Anaconda.