configuring jupyterlab#
To be able to run R from JupyterLab, we have one (possibly two) final pieces of configuration to do.
changing the terminal (windows only)#
If you are using Windows, we need to change the terminal from the default (PowerShell) to the Command Prompt
(CMD.exe). To begin, open the Anaconda Command Prompt, making sure that your intro-to-r
environment is
activated.
At the command prompt, enter the following command:
jupyter lab --generate-config
You should see something like the following:
Next, open the file (it should be located at %HOME%\.jupyter\jupyter_lab_config.py
, but check the output in
the command prompt) in Notepad++ or a similar text editor, and search for c.ServerApp.terminado_settings
(for me, this was at line 1062):
Inside of the curly brackets, add the following text:
'shell_command': [r'C:\WINDOWS\System32\cmd.exe']
Note
CMD.exe is, by default, located at %windir%\system32\cmd.exe
. To double-check that your %windir%
location is, in fact, C:\WINDOWS
, you can type echo %windir%
at the command prompt, and use the location
printed out from that command.
Once you have changed the file, save the changes, then close it. Now, launch JupyterLab from the command prompt
(again, making sure that your intro-to-r
environment is active):
jupyter lab
You should see a browser window like this open up:
If you don’t see this exactly, don’t worry. Click the blue + button in the upper left-hand corner of the window
to open the Launcher.
Next, click on Terminal under Other to launch a terminal window. You should see something like this:
If you don’t see a Command Prompt session with your intro-to-r
environment activated, please let me know
and I will do my best to help troubleshoot.
using R#
To check that JupyterLab is configured to run R, first launch JupyterLab from the
Anaconda Command Prompt, making sure that your intro-to-r
environment is activated:
jupyter lab
You should see a browser window like this open up:
Note
If you don’t see this exactly, don’t worry. Click the blue + button in the upper left-hand corner of the window to open the Launcher.
Next, click on R under the Console heading (second one down), to open the R Console:
If you see R | Idle
in the lower left-hand corner, as in the screenshot above, congratulations! You don’t need to
do anything further.
If, however, you don’t see this, go ahead and shut down JupyterLab (File > Shutdown). In your Command Prompt
window, open the R terminal by typing R
at the prompt and pressing Enter.
Finally, copy and paste (or type) the following into the console, which will tell Jupyter about the R kernel:
IRkernel::installspec()
When this finishes, type q()
and press enter to quit R.
To check that this has worked, re-launch JupyterLab and open the R console - you should now see that R is connected to JupyterLab, as in the screenshot above.