Kernel Error in R Notebook using Jupyter Notebook

2019-04-07 17:34发布

I am trying to use R within the jupyter notebook.

I went to my R shell and ran

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

Then I loaded up my ipython notebook and created a new notebook using the now available R extension. How ever when I access the notebook I run into this kernal error:

Traceback (most recent call last):
  File "C:\Users\Nina Kate\Anaconda3\lib\site-packages\IPython\html\base\handlers.py", line 394, in wrapper
    result = yield gen.maybe_future(method(self, *args, **kwargs))
  File "C:\Users\Nina Kate\Anaconda3\lib\site-packages\IPython\html\services\sessions\handlers.py", line 53, in     post
    model = sm.create_session(path=path, kernel_name=kernel_name)
  File "C:\Users\Nina Kate\Anaconda3\lib\site-packages\IPython\html\services\sessions\sessionmanager.py", line 66, in create_session
    kernel_name=kernel_name)
  File "C:\Users\Nina Kate\Anaconda3\lib\site-packages\IPython\html\services\kernels\kernelmanager.py", line 84, in start_kernel
    kernel_name=kernel_name, **kwargs)
  File "C:\Users\Nina Kate\Anaconda3\lib\site-packages\IPython\kernel\multikernelmanager.py", line 112, in start_kernel
km.start_kernel(**kwargs)
  File "C:\Users\Nina Kate\Anaconda3\lib\site-packages\IPython\kernel\manager.py", line 240, in start_kernel
**kw)
  File "C:\Users\Nina Kate\Anaconda3\lib\site-packages\IPython\kernel\manager.py", line 189, in _launch_kernel
return launch_kernel(kernel_cmd, **kw)
  File "C:\Users\Nina Kate\Anaconda3\lib\site-packages\IPython\kernel\launcher.py", line 202, in launch_kernel
proc = Popen(cmd, **kwargs)
  File "C:\Users\Nina Kate\Anaconda3\lib\subprocess.py", line 859, in __init__
restore_signals, start_new_session)
  File "C:\Users\Nina Kate\Anaconda3\lib\subprocess.py", line 1112, in _execute_child
startupinfo)
    FileNotFoundError: [WinError 2] The system cannot find the file specified

2条回答
啃猪蹄的小仙女
2楼-- · 2019-04-07 18:15

I was having exactly the same error in Windows 7. I added R to PATH environment variables and I was able to run it on shell but I was still having the kernel error in Jupyter.

The Kernel started working when installed system wide using:

IRkernel::installspec(user = FALSE)

instead of the first installation option:

IRkernel::installspec()

Note that it is necessary to set both parameters, the PATH variable and the R system wide install.

查看更多
Rolldiameter
3楼-- · 2019-04-07 18:31

You probably missed the warning up top about a missing index in the irkernel repo:

Warning: unable to access index for repository http://irkernel.github.io/src/contrib:
   cannot download all files

The new installation steps worked for me (in R 3.3 console):

install.packages('devtools')
devtools::install_github('IRkernel/IRkernel') # IRkernel-master.tar.gz
IRkernel::installspec()  # register kernel in the current R install
IRkernel::installspec(name = 'ir33', displayname = 'R 3.3')  # ir32, R 3.2

When you restart jupyter notebook, an "R 3.3" entry should appear in the list of kernels.

查看更多
登录 后发表回答