Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in loadNamespace(name) : there is no package called 'IRkernel' #583

Closed
loftusa opened this issue Sep 8, 2018 · 21 comments
Closed

Comments

@loftusa
Copy link

loftusa commented Sep 8, 2018

Hey all. I'm trying to get an R kernel up and running in jupyter lab. I'm completely new to R (but use Python a bunch) and I'm trying to get it installed so that I can start playing with it in an environment I'm familiar with.

I can click 'R' to make a new R kernel within jupyter, but when I actually try to do anything in the notebook it doesn't do anything and then says there's no kernel.

Anybody know what the issue might be? terminal code is copy/pasted below.

$ jupyter lab
[I 19:39:39.369 LabApp] The port 8888 is already in use, trying another port.
[W 19:39:39.378 LabApp] Terminals not available (error was No module named 'terminado')
[I 19:39:39.466 LabApp] JupyterLab beta preview extension loaded from C:\Anaconda\lib\site-packages\jupyterlab
[I 19:39:39.466 LabApp] JupyterLab application directory is C:\Anaconda\share\jupyter\lab
[I 19:39:39.744 LabApp] Serving notebooks from local directory: C:/Users/Alex Loftus/Dropbox/Programming/
[I 19:39:39.744 LabApp] 0 active kernels
[I 19:39:39.744 LabApp] The Jupyter Notebook is running at:
[I 19:39:39.744 LabApp] http://localhost:8889/?token=84033eeea5c929b4cb7324c9c9dbecd562efc7e733fc3b8e
[I 19:39:39.744 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 19:39:39.762 LabApp]

    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://localhost:8889/?token=84033eeea5c929b4cb7324c9c9dbecd562efc7e733fc3b8e
[I 19:39:39.957 LabApp] Accepting one-time-token-authenticated connection from ::1
[I 19:39:42.645 LabApp] Build is up to date
[I 19:39:43.173 LabApp] Kernel started: d9887cf8-91b0-4687-95e5-c7df132bac41
[I 19:39:43.212 LabApp] Kernel started: 998c1283-5d7d-48cf-899a-6fb93e04f532
Error in loadNamespace(name) : there is no package called 'IRkernel'
Calls: :: ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
[I 19:39:46.144 LabApp] KernelRestarter: restarting kernel (1/5), new random ports
Error in loadNamespace(name) : there is no package called 'IRkernel'
Calls: :: ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
[I 19:39:49.162 LabApp] KernelRestarter: restarting kernel (2/5), new random ports
Error in loadNamespace(name) : there is no package called 'IRkernel'
Calls: :: ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
[I 19:39:52.193 LabApp] KernelRestarter: restarting kernel (3/5), new random ports
Error in loadNamespace(name) : there is no package called 'IRkernel'
Calls: :: ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
[W 19:39:53.451 LabApp] Timeout waiting for kernel_info reply from d9887cf8-91b0-4687-95e5-c7df132bac41
[I 19:39:53.497 LabApp] Adapting to protocol v5.1 for kernel 998c1283-5d7d-48cf-899a-6fb93e04f532
[I 19:39:53.501 LabApp] Adapting to protocol v5.1 for kernel 998c1283-5d7d-48cf-899a-6fb93e04f532
[I 19:39:53.535 LabApp] Adapting to protocol v5.1 for kernel 998c1283-5d7d-48cf-899a-6fb93e04f532
[I 19:39:55.211 LabApp] KernelRestarter: restarting kernel (4/5), new random ports
kernel d9887cf8-91b0-4687-95e5-c7df132bac41 restarted
kernel d9887cf8-91b0-4687-95e5-c7df132bac41 restarted
kernel d9887cf8-91b0-4687-95e5-c7df132bac41 restarted
Error in loadNamespace(name) : there is no package called 'IRkernel'
Calls: :: ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
[W 19:39:58.245 LabApp] KernelRestarter: restart failed
[W 19:39:58.245 LabApp] Kernel d9887cf8-91b0-4687-95e5-c7df132bac41 died, removing from map.
kernel d9887cf8-91b0-4687-95e5-c7df132bac41 restarted failed!
kernel d9887cf8-91b0-4687-95e5-c7df132bac41 restarted failed!
kernel d9887cf8-91b0-4687-95e5-c7df132bac41 restarted failed!
[W 19:41:35.082 LabApp] delete /Jupyter-Notebooks/Learning/R/Untitled1.ipynb
[I 19:41:40.256 LabApp] Kernel shutdown: 998c1283-5d7d-48cf-899a-6fb93e04f532
[W 19:41:40.267 LabApp] delete /Jupyter-Notebooks/Learning/R/Untitled.ipynb
[I 19:41:43.039 LabApp] Creating new notebook in /Jupyter-Notebooks/Learning/R
[I 19:41:43.344 LabApp] Kernel started: 3da0d49b-d215-4e18-ae25-c585d54e1bd7
Error in loadNamespace(name) : there is no package called 'IRkernel'
Calls: :: ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
[I 19:41:46.345 LabApp] KernelRestarter: restarting kernel (1/5), new random ports
Error in loadNamespace(name) : there is no package called 'IRkernel'
Calls: :: ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
[I 19:41:49.376 LabApp] KernelRestarter: restarting kernel (2/5), new random ports
Error in loadNamespace(name) : there is no package called 'IRkernel'
Calls: :: ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
[I 19:41:52.425 LabApp] KernelRestarter: restarting kernel (3/5), new random ports
Error in loadNamespace(name) : there is no package called 'IRkernel'
Calls: :: ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
[W 19:41:53.383 LabApp] Timeout waiting for kernel_info reply from 3da0d49b-d215-4e18-ae25-c585d54e1bd7
[I 19:41:55.446 LabApp] KernelRestarter: restarting kernel (4/5), new random ports
kernel 3da0d49b-d215-4e18-ae25-c585d54e1bd7 restarted
kernel 3da0d49b-d215-4e18-ae25-c585d54e1bd7 restarted
kernel 3da0d49b-d215-4e18-ae25-c585d54e1bd7 restarted
Error in loadNamespace(name) : there is no package called 'IRkernel'
Calls: :: ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
[W 19:41:58.471 LabApp] KernelRestarter: restart failed
[W 19:41:58.471 LabApp] Kernel 3da0d49b-d215-4e18-ae25-c585d54e1bd7 died, removing from map.
kernel 3da0d49b-d215-4e18-ae25-c585d54e1bd7 restarted failed!
kernel 3da0d49b-d215-4e18-ae25-c585d54e1bd7 restarted failed!
kernel 3da0d49b-d215-4e18-ae25-c585d54e1bd7 restarted failed!
[I 19:43:43.579 LabApp] Saving file at /Jupyter-Notebooks/Learning/R/Untitled.ipynb
@flying-sheep
Copy link
Member

it says

Error in loadNamespace(name) : there is no package called 'IRkernel'

so apparently you didn’t install IRkernel. did you follow the install instructions?

@loftusa
Copy link
Author

loftusa commented Sep 10, 2018

Yep! Many times, with multiple variations, and in multiple kernel environments. I also tried manually dropping the IRkernel folder into a packages subdirectory - couldn't get anything to work.

@flying-sheep
Copy link
Member

flying-sheep commented Sep 10, 2018

a common source of problems: the kernel is started directly from R, not inside of a shell. so if you set environment variables in .bashrc or so, the kernel doesn’t get them

to check which R binary is used you can do this (supply “ir” with your chosen kernelspec ID):

$ r_bin=$(jupyter kernelspec list --json | jq -r '.kernelspecs.ir.spec.argv[0]')
$ echo $r_bin
/usr/lib64/R/bin/R
$ env -i $r_bin --slave -e 'library(IRkernel)'

You should be able to do the above without an error. If you can’t, you need to fix that.

Could you check? (if you don’t have and want jq installed, just search for the path to the R binary in the output of jupyter kernelspec list --json)

@michaelvanvliet
Copy link

@loftusa I had to patch the ../anaconda3/share/jupyter/kernels/ir/kernel.json to point to the correct version of R, which wasn't the default version installed by the OS.

@flying-sheep
Copy link
Member

In case this doesn’t fix the problem, please tell me and I’ll reopen this

@scyurt
Copy link

scyurt commented Feb 6, 2019

I have the same problem after I installed R version 3.5.2. I tried to modify the kernel.json and installed again and again but no luck. anyone knows how to solve this? "there is no package called 'IRkernel'"

@flying-sheep
Copy link
Member

flying-sheep commented Feb 7, 2019

did you read this comment?

@scyurt
Copy link

scyurt commented Feb 7, 2019

yes, I did. it did not work for me.

@flying-sheep
Copy link
Member

flying-sheep commented Feb 8, 2019

So the code above gave you “there is no package called 'IRkernel'”.

That means that IRkernel is not installed for the R version that Jupyter tries to use.

which R gives you the version that opens when you just type R on your cmdline. If you install IRkernel from that, the output of which R needs to match the output of jupyter kernelspec list --json | jq -r '.kernelspecs.ir.spec.argv[0]'. If it doesn’t match you need to edit the kernel.json to contain the path from which R.

@mfigrs
Copy link

mfigrs commented Feb 11, 2019

Hi, I am having the same type of problem. This happened to me on a Mac and a Win10 PC. I solved it on the Mac by... removing hydrogen whatsoever and using another Atom plugin to execute R. However, on the PC I need to run both Python and R. Here is my kernelspec list, section on R:

"ir": {
      "spec": {
        "argv": [
          "C:/PROGRA~1/R/R-35~1.2/bin/x64/R",
          "--slave",
          "-e",
          "IRkernel::main()",
          "--args",
          "{connection_file}"
        ],
        "display_name": "R",
        "env": {},
        "language": "R"
      },
      "resource_dir": "C:\\Users\\Michal\\AppData\\Roaming\\jupyter\\kernels\\ir"
    },

The paths are correct and the referenced R has IRkernel package installed. Moreover, R is working perfectly in Jupyter Notebook - just not in Atom+hydrogen.

Also, if I execute the command C:/PROGRA~1/R/R-35~1.2/bin/x64/R in a terminal, and then execute library(IRkernel) the library loads and I get no error message.

@flying-sheep
Copy link
Member

Well, I never understood the weird shortened windows paths, so have you tried using the full path?

@xiaodaigh
Copy link

I am still having issues here. If it's can't find the libraries then it must mean that it's not looking into the right directory for the libraries.

@flying-sheep
Copy link
Member

Yes, but if you start

  1. the same R that you specified in the kernel.json
  2. with the same environment variables set (i.e. starting both from e.g. a terminal)
  3. and the library loads

I don’t have the slightest idea why it wouldn’t load when you start the IRernel.

@xiaodaigh
Copy link

It's working for me now but I had to change this line to force it to read from the right library

".libPath('path/to/your/r/libs/');IRkernel::main()",

@flying-sheep
Copy link
Member

Great! I have no idea which kinds of setup lead to this.

I can’t just add something to kernel.json that sets $R_LIBS_USER or $R_LIBS_SITE because this would mess with the library paths inside of the running kernel.

So I think users with weird setups like you need to fix that themselves.

@kbmorales
Copy link

Don't mean to necro an old issue, but I encountered this and think this is a common issue for Windows users who use RStudio to install the package. The problem is the .libPath assumptions. .libPath() prioritizes the user-specific lib in RStudio, but the general R install lib in shell, which can result in some users having packages installed in multiple libraries.

Setting a user environment variable R_LIBS_USER to your user-specific library resolved the issue for me.

@flying-sheep
Copy link
Member

Ah nice. I don’t think we can improve this somehow from our side? Maybe detect if RStudio is early in the .libPath() and complain then?

@kbmorales
Copy link

Cant really think of an easy way for this package to check--users just gotta be conscious of where packages are installing. May be possible to check all paths returned by libsPath and or ask the user to choose a libsPath entry if > 1

@rsokolewicz
Copy link

rsokolewicz commented Dec 23, 2021

I had this issue today when a colleague pushed her renv environment to the project repository. When jupyter tries to load the R kernel, the renv environment takes precedence and will completely ignore my conda environment. Solution is either to delete the renv, or to install IRKernel inside the renv environment (i.e. open your R interpreter inside the project folder and run install.packages('IRKernel')).

It's not something for you guys to fix, but just putting it here in case someone has the same issue.

@liujilei156231
Copy link

@flying-sheep Hi,Could you please give me some advice ?

On a linux server, jupyter-notebook and R-4.2.0 have been installed in a storage disk where I could not write.
But , in my home ,I have installed IRkernel and could be loaded correctly.
And I successfully added a R kernel into the jupyter-notebook with the following code IRkernel::installspec()
image

But I failed when creating an R notebook.
note:

[W 22:50:15.509 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20230417224957 (10.440000ms referer=http://xxxx/notebooks/%E6%9C%AA%E5%91%BD%E5%90%8D.ipynb?kernel_name=ir
[I 22:50:15.512 NotebookApp] Kernel started: 4529345a-50e5-4099-b66b-03c78e850604, name: ir
Error in loadNamespace(x) : 不存在叫‘IRkernel’这个名字的程辑包
Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
停止执行
[I 22:50:18.499 NotebookApp] KernelRestarter: restarting kernel (1/5), new random ports
Error in loadNamespace(x) : 不存在叫‘IRkernel’这个名字的程辑包
Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
停止执行
[I 22:50:21.522 NotebookApp] KernelRestarter: restarting kernel (2/5), new random ports
Error in loadNamespace(x) : 不存在叫‘IRkernel’这个名字的程辑包
Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
停止执行
[I 22:50:24.546 NotebookApp] KernelRestarter: restarting kernel (3/5), new random ports
Error in loadNamespace(x) : 不存在叫‘IRkernel’这个名字的程辑包
Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
停止执行
[I 22:50:27.570 NotebookApp] KernelRestarter: restarting kernel (4/5), new random ports
Error in loadNamespace(x) : 不存在叫‘IRkernel’这个名字的程辑包
Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
停止执行
[I 22:50:30.595 NotebookApp] KernelRestarter: restarting kernel (5/5), new random ports
Error in loadNamespace(x) : 不存在叫‘IRkernel’这个名字的程辑包
Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
停止执行
[W 22:50:33.620 NotebookApp] KernelRestarter: restart failed

Here's a reminder that IRkernel doesn't exist.
So the problem seems to be that the R-library loaded by the jupyter notebook is not my home librariry. How do I get jupyter-notebook to load two R-libraries at the same time?

@flying-sheep
Copy link
Member

I can’t read the language that error text is in so I can’t help you here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants