How to install Jupyter Lab/Notebook on Windows 10? - r

I have been using R/Python and Jupyter Lab/Notebook on Macbook. In my new job, I need to install and run these applications on Windows 10.
I have Python, pip, Jupyter, R4.1 & RStudio installed manually (not through Anaconda). I try to execute step 2/3: Making the kernel available to Jupyter based on installation guide. I got error message in R Console.
> IRkernel::installspec()
Error in IRkernel::installspec() :
jupyter-client has to be installed but “jupyter kernelspec --version” exited with code 127.
In addition: Warning message:
In system2("jupyter", c("kernelspec", "--version"), FALSE, FALSE) :
'"jupyter"' not found
Appreciate your advice.

Please check if jupyter is in your user/system path. A quick way to check is by running jupyter in the command line, you could use powershell commandline:
Get-Command jupyter
CommandType Name Version Source
----------- ---- ------- ------
Application jupyter.exe 0.0.0.0 C:\Users\youruser\AppData\Local\Programs\...
If it's not there, then you can add to your system/user path and check with new instance of commandline again.

Related

Install R in jupyter notebook

I am trying to instal R in jupyter notebook after I updated recently my R version (currently it is 4.1.3).
I passed line by line after the instructions but in the last step (did it in anaconda prompt), I faced this error message:
Error in IRkernel::installspec() :
jupyter-client has to be installed but "jupyter kernelspec --version" exited with code 1.
I found similar errors in the net, but not with "exited with code 1."
I think the update of the R-version has changed something in Anaconda and it is doesn't recognize by it (maybe re-install R in anaconda, but I am not sure if so, and how to do it).
can someone help with it?
thanks

Installing R 4.0.2 version

I used to work in R 3.4.0 version. Hovewer, this version doesn't support such packages as keras and tensorflow.
I was adviced to upgrade my R version to the newest one.
I downloaded the most recent R version 4.0.2 from the official site, then ran the following code:
install.packages("keras")
library(keras)
install_keras()
And got the following error:
Error in install_keras() :
You should call install_keras() only in a fresh R session that has not yet initialized Keras and TensorFlow (this is to avoid DLL in use errors during installation)
After this, when I tried to quit R session by q() , I faced the following error:
Error: option error has NULL value
Error: no more error handlers available (recursive errors?); invoking 'abort' restart
Error: option error has NULL value
I've never faced such an error before. When I used old R version, I typed q() and then had to choose between y and n. No errors appeared.
I'm asking you to help to to solve this problem.
You need to create a new environment and then you can install R 4.+ in Anaconda. Follow these steps.
conda create --name r4-base
After activating r4-base run these commands
conda activate r4-base
conda install -c conda-forge r-base
conda install -c conda-forge/label/gcc7 r-base
Finally, you will notice r-basa version 4 will be installed.
Thereafter, you can install any supported packages. But with this only, you won't have the ability to use it in the Jupyter notebook. You need to install install.packages('IRkernel') and Jupyter notebook as well if you want to use it. Otherwise you are good to go with R-Studio.
For Jupyter Installation and RKernel.
conda install jupyter
Then open the R console. Write in R console
install.packages('IRkernel')
IRkernel::installspec()
Congrats! You can use Notebook for Python and R.
Find the location of R.exe on your computer. In my computer, this executable is at
C:\Program Files\R\R-3.4.3\bin
Open another Anaconda Prompt as Administrator and change directories to wherever R.exe is on your computer with cd file path. On my computer, it’s cd C:\Program Files\R\R-3.4.3\bin, but it might be different for you.
Then run R from within Anaconda Prompt in Admin mode with R.exe
You’ll notice that you’re in an R session. From here, run the following three commands into the terminal.
install.packages("devtools")
devtools::install_github("IRkernel/IRkernel")
IRkernel::installspec()
In order, they (1) install the devtools package which gets you the install_github() function, (2) install the IR Kernel from GitHub, and (3) tell Jupyter where to find the IR Kernel.
Open Jupyter notebook and enjoy your new R kernel!
Get more information here
#Rheatey Bash works perfectly. but i was facing python.exe this program cant start because api-ms-win-core-path-l1-1-0.dll python system error. this is a problem running on windows 7 but i resolved this issue by installing the kernel following https://richpauloo.github.io/2018-05-16-Installing-the-R-kernel-in-Jupyter-Lab/ and it works fine

Using R with Jupyter notebook installation

I have installed R from the official site and want to use it from jupyter notebook and jupyterlab. For that i have installed IRkernal in R using:
install.packages('IRkernel')
and then when I type IRkernel::installspec(user = FALSE) to make this installation visible globally,
I get following error:
Error in IRkernel::installspec(user = FALSE) :
jupyter-client has to be installed but “jupyter kernelspec --version” exited with code 127.
In addition: Warning message:
In system2("jupyter", c("kernelspec", "--version"), FALSE, FALSE) :
'"jupyter"' not found
I have jupyter installation on miniconda and I don't want to use the conda distribution of R. What should I do?
The command to setup IRkernel has to be run in the same environment as the jupyter installation. Due to this, It won't work with R.exe directly. For this, you have to run the command IRkernel::installspec(user=FALSE) in the Anaconda prompt.

Cannot get IRkernel::installspec() to work, jupyter-client not visible

I am still in progress to get Jupyter-Notebook and R working together on Windows 10 machine. After solving the problem with install_github() I am now facing just another issue. I am still following the official installation guide, I am stuck at step 2:
Every time I get this error - I have tried this in R GUI and RStudio, the same:
> IRkernel::installspec()
Error in IRkernel::installspec() :
jupyter-client has to be installed but “jupyter kernelspec --version” exited with code 127.
In addition: Warning message:
In system2("jupyter", c("kernelspec", "--version"), FALSE, FALSE) :
'"jupyter"' not found
My attempts so far: It was suggested here and here, that this could be a problem with the PATH variable setting, so I have added Anaconda to the PATH enviroment. I also installed the jupyter-client via the Anaconda console. No change so far. Any ideas?
This answer is based on this by #Ryan, but since the question answered was actually about a Linux based system I put it here in a Windows question:
One way to overcome the problem - if adding PATH variables to the environment doesn't work - is the following:
If Anaconda is installed and the Jupyter-Notebook with it (should be the standard install), open up the Anaconda prompt, not the Windows command prompt or the Anaconda Navigator
Look up the executable of R (not Rgui or Rstudio), it should be somewhere like C:\Program Files\R\R-3.5.1\bin and copy the path
Paste the path into the Anaconda prompt and start R by typing R
Now execute IRkernel::installspec() once again, this time there shouldn't be an error
Now you can start an R kernel within Jupyter-Notebook
You should try to open R in the terminal, if you changed directory where R il located type:
R.exe
and then run:
IRkernel::installspec()
I was having this issue trying to run Jupyter Lab on my Ubuntu 18.04 LTS headless server running in an Azure VM.
To resolve the issued, I had to navigate to /usr/bin and open R from there. It turns out that despite my path, calling R from the terminal opened the anaconda3 version in /home/<you>/anaconda3/bin/R.
Run IRkernel::installspec() from /usr/bin/R in as sudo and it should add the kernel.
If jupyter.exe is installed under c:\python36\sripts, run
"setwd("c:/python36/scripts")" on R GUI, run "IRkernel::installspec()"
Simply create a new virtual environment for R. Either using the CLI or the anaconda Navigator (best recommended, If and if you're using Anaconda).

Error code 127 when adding R kernal to Jupyter Notebook

I am aware that this question has been asked before but it was a long time ago and all of the advice in the thread didn't work for me. I have anaconda installed on my Windows 10 computer. Jupyter Notebook works fine but I want to add the R kernel. I have installed the IRkernel package and ran IRkernel::installspec() but I get the error message:
Error in IRkernel::installspec() :
jupyter-client has to be installed but "jupyter kernelspec --version" exited with code 127.
In addition: Warning message:
running command '"jupyter" kernelspec --version' had status 127
I ran this in the R console and I have added C:\ProgramData\Anaconda3\Lib\site-packages\jupyter_client and C:\ProgramData\Anaconda3\Scripts to the system PATH as advised in the old question but to no avail. Is there any advice specific to my setup (as the previous question was for an Ubuntu machine) that would fix this?
Ah I figured out what I needed to do. I'll leave an answer here in case anyone else has the same issue in the future.
Executing from either RStudio or R console wasn't working. Instead I had to run R in the anaconda console and then run the command and it worked without an error.
I had the same problem. Updated the paths, exactly as you have. Kept getting errors when I tried
devtools::install_github('IRkernel/IRkernel')
claiming that 'digest' wasn't available. I also got 'status 127' when attempting to execute
IRkernel::installspec(user = FALSE)
What seems to have worked for me was to execute
install.packages(c('repr', 'IRdisplay', 'evaluate', 'crayon', 'pbdZMQ', 'devtools', 'uuid', 'digest'))
in RStudio. Then, in R console, I executed the other commands. No errors, and I verified that I now have the option for R in the dropdown for 'New'.

Resources