15

I'm pretty new to the forum, so I'm sorry if this question has already been answered. I looked around, and although I saw that some had similar issues, I couldn't find the solution to my problem on any previous posts. So - here goes...

I'm running Mac OS X 10.11.5, Jupyter notebook version 4.2.1, R version 3.2.2

I installed the R kernel for Jupyter notebook with the following command -

conda install -c r r-irkernel

Now, when I launch Jupyter notebook, I see 'R' appears as one of the options in the drop down menu on the right hand side under 'notebooks.' However, when I try to create an R notebook, the kernel crashes and I get the following error in terminal:

WARNING:root:kernel b42781ab-ebb1-45eb-8a54-d3801106fb94 restarted
Error: .onLoad failed in loadNamespace() for 'pbdZMQ', details:  
  call: dyn.load(file, DLLpath = DLLpath, ...)
  error: unable to load shared object '/Users/avislova/anaconda/lib/R/library/pbdZMQ/libs/pbdZMQ.so':
  dlopen(/Users/avislova/anaconda/lib/R/library/pbdZMQ/libs/pbdZMQ.so,     6): Library not loaded: @rpath/libzmq.5.dylib
  Referenced from: /Users/avislova/anaconda/lib/R/library/pbdZMQ/libs/pbdZMQ.so
  Reason: image not found
Execution halted
 [W 16:19:12.382 NotebookApp] KernelRestarter: restart failed
 [W 16:19:12.382 NotebookApp] Kernel b42781ab-ebb1-45eb-8a54-d3801106fb94 died, removing from map.
ERROR:root:kernel b42781ab-ebb1-45eb-8a54-d3801106fb94 restarted failed!
 [W 16:19:12.390 NotebookApp] Kernel deleted before session
 [W 16:19:12.390 NotebookApp] 410 DELETE /api/sessions/2236e334-e33a-483b-87f3-31c461d4903b (::1) 1.32ms referer=http://localhost:8888/notebooks/Untitled5.ipynb?kernel_name=ir

Any idea where I can go from here?

Thank you!

A. Vislova
  • 343
  • 2
  • 3
  • 10
  • Does installing zeromq (`conda install zeromq`) solve the issue for you? – cel Jul 15 '16 at 05:53
  • I tried that and also removed the package IRkernel in R (with intention to reinstall it) and now I am unable to reinstall IRkernel. When I run `devtools::install_github(c('IRkernel/IRdisplay', 'IRkernel/IRkernel'))` in R I get the error `sh: /usr/bin/gnutar: No such file or directory; Error in system(cmd, intern = TRUE) : error in running command`. When I attempt to launch IRKernel in Jupyter, I get the error `Error in loadNamespace(name) : there is no package called ‘IRkernel’`. Also, I am unable to to install package 'pbdZMQ' in R - I think this may be the root of the problem. – A. Vislova Jul 15 '16 at 06:28
  • 1
    what I would try now: install conda's r-kernel `conda install -c r r-irkernel zeromq`, then start R from the command line and remove `pdbZMQ`. Next install `pdbZMQ` again in R and close the R interpreter. Start jupyter, open a notebook with IRkernel and try to import `pdbZMQ`. – cel Jul 15 '16 at 06:39
  • `> remove.packages('pbdZMQ') Removing package from ‘/Users/avislova/anaconda/lib/R/library’ (as ‘lib’ is unspecified) Error in find.package(pkgs, lib) : there is no package called ‘pbdZMQ’ > install.packages('pdbZMQ') Warning message: package ‘pdbZMQ’ is not available (for R version 3.3.1)` This is different from the error I was getting earlier when I was trying to install 'pdbZMQ'. Anyways, is there a different way to try to install it? By the way, thanks a lot! – A. Vislova Jul 15 '16 at 06:57
  • For some reason, I am able to make more progress when I try to install pbdZMQ like this `> install.packages(c('repr', 'pbdZMQ', 'devtools'))` But I am still getting the error: `Error : .onLoad failed in loadNamespace() for 'pbdZMQ', details: call: dyn.load(file, DLLpath = DLLpath, ...) error: unable to load shared object '/Users/avislova/anaconda/lib/R/library/pbdZMQ/libs/pbdZMQ.so': dlopen(/Users/avislova/anaconda/lib/R/library/pbdZMQ/libs/pbdZMQ.so, 6): Library not loaded: @rpath/libsodium.4.dylib Referenced from: /Users/avislova/anaconda/lib/libzmq.4.dylib` (like original error) – A. Vislova Jul 15 '16 at 07:09

3 Answers3

9

I faced similar issue after I updated 'R' on my mac.

Below steps resolved my issue

install.packages(c('pbdZMQ', 'repr', 'devtools'))  
devtools::install_github('IRkernel/IRdisplay')
devtools::install_github('IRkernel/IRkernel')
IRkernel::installspec()  

For details refer http://johnlaudun.org/20160521-irkernel-difficulties/

Jeevan
  • 8,532
  • 14
  • 49
  • 67
3

I frequently find myself reinstalling systems; further to @Jeevan, I always run the following in R at the end of my 'R install process':

install.packages(c("knitr", "ggplot2","rpart.plot","devtools","ggvis","psych","dplyr","tidyr","rvest","magrittr","testthat","roxygen2"),dependencies=TRUE)
#--> set Sweave to knitr

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

IRkernel::installspec()
Jeevan
  • 8,532
  • 14
  • 49
  • 67
George Fisher
  • 3,046
  • 2
  • 16
  • 15
1

After installing devtools in R:

> install.packages("devtools")

Try installing the following from github:

> library("devtools")
> devtools::install_github("IRkernel/repr")
> devtools::install_github("IRkernel/IRdisplay")
> devtools::install_github("IRkernel/IRkernel")

The last line installed pdbZMQ for me, even though using install.packages("pdbZMQ") reported that none existed for any of the versions of R I tried.

More details and troubleshooting are available on github where I found this solution.

mightypile
  • 7,589
  • 3
  • 37
  • 42