Search code examples
rjupyterosx-elcapitan

Juypter notebook can't find R kernel on El Capitan public beta


I installed the El Capitan beta on a spare computer for test purposes to try to identify potential issues before others in our data science team upgrade their day to day machines once the final release is out sometime this fall (Note: I can navigate around Unix but I am far from a Mac programmer). The kernels for python 2 and 3 work just fine, but when I try to load the R kernel I get the following messages:

From within the Jupyter notebook itself I get:

Traceback (most recent call last):
  File "/Users/test/anaconda/lib/python3.4/site-packages/IPython/html/base/handlers.py", line 365, in wrapper
    result = yield gen.maybe_future(method(self, *args, **kwargs))
  File "/Users/test/anaconda/lib/python3.4/site-packages/IPython/html/services/sessions/handlers.py", line 53, in post
    model = sm.create_session(path=path, kernel_name=kernel_name)
  File "/Users/test/anaconda/lib/python3.4/site-packages/IPython/html/services/sessions/sessionmanager.py", line 66, in create_session
    kernel_name=kernel_name)
  File "/Users/test/anaconda/lib/python3.4/site-packages/IPython/html/services/kernels/kernelmanager.py", line 84, in start_kernel
    kernel_name=kernel_name, **kwargs)
  File "/Users/test/anaconda/lib/python3.4/site-packages/IPython/kernel/multikernelmanager.py", line 112, in start_kernel
    km.start_kernel(**kwargs)
  File "/Users/test/anaconda/lib/python3.4/site-packages/IPython/kernel/manager.py", line 240, in start_kernel
    **kw)
  File "/Users/test/anaconda/lib/python3.4/site-packages/IPython/kernel/manager.py", line 189, in _launch_kernel
    return launch_kernel(kernel_cmd, **kw)
  File "/Users/test/anaconda/lib/python3.4/site-packages/IPython/kernel/launcher.py", line 213, in launch_kernel
    proc = Popen(cmd, **kwargs)
  File "/Users/test/anaconda/lib/python3.4/subprocess.py", line 859, in __init__
    restore_signals, start_new_session)
  File "/Users/test/anaconda/lib/python3.4/subprocess.py", line 1457, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'R'

And I get the following error messages in the Terminal.

[E 19:44:58.862 NotebookApp] Unhandled error in API request
    Traceback (most recent call last):
      File "/Users/test/anaconda/lib/python3.4/site-packages/IPython/html/base/handlers.py", line 365, in wrapper
        result = yield gen.maybe_future(method(self, *args, **kwargs))
      File "/Users/test/anaconda/lib/python3.4/site-packages/IPython/html/services/sessions/handlers.py", line 53, in post
        model = sm.create_session(path=path, kernel_name=kernel_name)
      File "/Users/test/anaconda/lib/python3.4/site-packages/IPython/html/services/sessions/sessionmanager.py", line 66, in create_session
        kernel_name=kernel_name)
      File "/Users/test/anaconda/lib/python3.4/site-packages/IPython/html/services/kernels/kernelmanager.py", line 84, in start_kernel
        kernel_name=kernel_name, **kwargs)
      File "/Users/test/anaconda/lib/python3.4/site-packages/IPython/kernel/multikernelmanager.py", line 112, in start_kernel
        km.start_kernel(**kwargs)
      File "/Users/test/anaconda/lib/python3.4/site-packages/IPython/kernel/manager.py", line 240, in start_kernel
        **kw)
      File "/Users/test/anaconda/lib/python3.4/site-packages/IPython/kernel/manager.py", line 189, in _launch_kernel
        return launch_kernel(kernel_cmd, **kw)
      File "/Users/test/anaconda/lib/python3.4/site-packages/IPython/kernel/launcher.py", line 213, in launch_kernel
        proc = Popen(cmd, **kwargs)
      File "/Users/test/anaconda/lib/python3.4/subprocess.py", line 859, in __init__
        restore_signals, start_new_session)
      File "/Users/test/anaconda/lib/python3.4/subprocess.py", line 1457, in _execute_child
        raise child_exception_type(errno_num, err_msg)
    FileNotFoundError: [Errno 2] No such file or directory: 'R'
[E 19:44:58.870 NotebookApp] {
      "Accept-Language": "en-US,en;q=0.8",
      "Content-Length": "72",
      "Accept": "application/json, text/javascript, */*; q=0.01",
      "Dnt": "1",
      "X-Requested-With": "XMLHttpRequest",
      "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
      "Origin": "http://localhost:8888",
      "Referer": "http://localhost:8888/notebooks/Untitled4.ipynb?kernel_name=ir",
      "Accept-Encoding": "gzip, deflate",
      "Connection": "keep-alive",
      "Host": "localhost:8888",
      "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.132 Safari/537.36"
    }
[E 19:44:58.870 NotebookApp] 500 POST /api/sessions (::1) 25.54ms referer=http://localhost:8888/notebooks/Untitled4.ipynb?kernel_name=ir
[I 20:04:04.914 NotebookApp] Creating new notebook in
[I 20:04:05.707 NotebookApp] Kernel started: 75ef1aa5-453d-4a18-94df-eae30238c688

My first thought was to try to reinstall the R kernel (and its dependencies), but those dependencies must be compiled from their binaries and require Xcode (for which there is not a public beta). Does anyone know of a potential work around for this (or have any ideas about where to start looking)? I'm trying to figure out if this is something we can fix on our own or if we will likely need to wait on an official fix from the Jupyter group. Thanks in advance.


Solution

  • Was able to get this working. Updating to beta messed with the R $PATH as well as homebrew and its dependencies. Taking the following steps has fixed all of the issues I was experiencing.

    1) Reinstall Revolution R Open (or your preferred R install. I like RRO because it includes the Intel MKL - Math Kernel Library)

    2) Fix Homebrew permissions:

    $ sudo chown -R "$USER":admin /usr/local
    

    3) Cleanup Homebrew Install:

    $ rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
    

    4) Reinstall Homebew:

    $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    

    5) Install OS X command line tools (if not already installed):

    $ xcode-select --install
    

    6) Install zqm:

    $ brew install zmq
    

    7) Launch R in terminal

    $R
    

    8) Run the following:

    install.packages(c('rzmq','repr','IRkernel','IRdisplay'),
                     repos = c('http://irkernel.github.io/', getOption('repos')),
                     type = 'source')
    IRkernel::installspec()
    

    Opening a new terminal window and launching jupyter should now work.