I recently installed the Anaconda3 distribution and I want to have the R and Julia Kernels available besides Python. I use windows 10.
To install IJulia I installed the Julia language and follewed the steps indicated in the IJulia page; everything went fine.
To install the R kernel I used the command conda install -c r r-essentials in the anaconda command prompt, again, no problems. I also installed R.
When I launch the notebook the only available kernel is Python, the R and Julia kernels doesn't appear in the list, I have no clue why this since I got no errors in the installation of IJulia and IRKernel. Anyone could help?
After a fresh installation of Anaconda Distribution (either 2 or 3), following steps should be performed to achieve the desired kernels (R & Julia) on your notebook.
To install R on Anaconda(2/3) Jupyter Notebook :
Open 'Anaconda Command Prompt' & execute conda update notebook to update your Jupyter notebook to the most recent version.
Then install IRkernel by conda install -c r notebook r-irkernel
Now you may open R in your command prompt by running R.exe
Install all necessary R packages using the following lines in the R console by executing :
install.packages(c('repr', 'IRdisplay', 'evaluate', 'crayon', 'pbdZMQ',
'devtools', 'uuid', 'digest'))
devtools::install_github('IRkernel/IRkernel')
Finally, make the R kernel available to your Jupyter Notebook by executing:
Install only for the current user ➡ IRkernel::installspec()
For System-wide installation(all Users) ➡ IRkernel::installspec(user = FALSE)
To install Julia on Anaconda(2/3) Jupyter Notebook :
First, download Julia version 0.4 or later and run the installer. Then run the Julia application (double-click on it); the Julia Console with a julia> prompt will appear.
Now, for the most important step, open 'Anaconda Command Prompt' & execute where jupyter to see the actual path of your Jupyter Notebook. The output will be something like "C:\Users\JohnDoe\AppData\Local\Continuum\Anaconda3\bin\jupyter.exe"
Copy the above location and go to your Julia console. Now, execute the following respectively:
ENV["JUPYTER"]="C:\\Users\\JohnDoe\\AppData\\Local\\Continuum\\Anaconda3\\bin\\jupyter.exe"
Pkg.add("IJulia")
Pkg.build("IJulia") (Optional, execute if further error occurs again.)
⬆ Notice that the backslashes have to be doubled when you type them as a Julia string. I've just assumed that the path is your Anaconda path with \bin\jupyter appended, but replace that with whatever where jupyter tells you.
After few minutes, in Julia console execute:
using IJulia
notebook()
Now, you can program Julia in your Anaconda Jupyter Notebook.
Excellent, it worked.
However, it is important to import the package first before adding it.
import Pkg; Pkg.add("IJulia")
Related
Summary
Installed R kernel in Anaconda environment
Works with Anaconda's browser Jupyter notebook, but not VS Code.
Details
I am trying to set up VS Code to recognize my R kernel for use with Jupyter Notebooks. The steps I have followed are as follows:
Create a new R environment (via the Anaconda interface... Rstudio works just fine).
Using the command line interface with the above environment activated, ensure Jupyter is installed: conda install jupyter
Install irkernel: conda install -c r r-irkernel
Run R from command line and initialize irkernel:
R
> IRkernel::installspec()
Open VS Code and create a new notebook. Select the R kernel that appears, and run a basic commannd in the first cell: file.path(getwd())
These follow the steps here, and in other Stackoverflow posts (here and here).
Unfortunately, I cannot get the kernel to work. The above code in item 5 results in the following error:
Failed to start the Kernel.
The kernel died. Error: ... View Jupyter log for further details.
There is a copy of the log available here (should be visible to everyone). The notebook is available here (but is literally just the one line of code mentioned above).
My hypothesis is that IRkernel::installspec() installs the kernel in a different location than the conda environment. The kernel is installed in C:\Users\aaron\AppData\Roaming\jupyter\kernels\ir, while in VS Code the kernel selected is in C:\Users\aaron\.conda\envs\rstudio\lib\R\bin\x64\R (the environment name is rstudio).
However, when I open Jupyter notebook via the Anaconda interface (not VS Code... i.e. the browser version), everything works just fine. The same code (file.path(getwd())) returns the appropriate 'C:/Users/aaron'.
I am sure I have done something silly wrong, and appreciate your help in advance!
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
I'm facing difficulties downloading the r package rsvg. I created first an environment with conda for the latest R version 4.0.2 following these instructions. I was able to download many other R packages & bioconductor packages without problem, however, this one produces huge pile of lines while configuring it and ends with errors downloadind its dependencies (systemfonts, stringi, stringr, gdtools, magick, svglite, knitr). My exact command is install.packages("rsvg", dependencies =T). Trying to download each of those packages produced also a tree of required dependencies (with configuration fail at the end of each).
Among the lines I noticed this error /user/include/freetype2/freetype/config/ftheader.h:3:12: fatal error x86_64-linux-gnu/freetype2/config/fthreader.h no such file or directory which make me suspect that my R installation is incopmlete or corrupted. I tested it with other R versions (e.g. R 3.6.0) yet the same error appear. Installing it on windows (Rstudio 3.6.2) also didn't work, and now I'm wondering if this package needs to be installed differently or it is system related problem? Any help would be highly appreciated
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 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.
I have jupyter notebook installed, I also have R installed. Both work fine independently.
When I run jupyter with jupyter notebook, then try to open an ipynb file, I see
The only option in the dropdown is Python 3 (R is not an option).
Question
How do you open a jupyter notebook with an R kernel (on mac)?
Note
I tried jupyter notebook --runtime-dir /usr/local/bin/R but that was just guessing
Looks like the R kernel could be installed via pip?
Open any R session (e.g. in RStudio is fine, or open terminal/bash and type R to start an R session).
Install the kernel with:
install.packages("devtools")
devtools::install_github("IRkernel/IRkernel")
IRkernel::installspec()
Close and reopen the notebook and the R kernel will now be available.
If the R kernel does not appear as an option within a Jupyter notebook even after installing R, and one is using Anaconda, bringing up the conda prompt from the Start menu (Windows 10), and running the following commands may do the trick:
conda config --add channels r
conda install --yes r-irkernel
Credit to this post.
I use conda python environment. I start the Jupyter lab following the steps below:
$conda activate <env_name>
$jupyter lab --no-browser --port=8080 &
Now, from a jupyter lab notebook, when I try to import feather (import feather), it fails with Module Not Found message.
From the jupyter lab notebook, if I execute the following, it shows me that feather is present:
! conda list | grep feather
Now, if I shutdown Jupyter Lab in the same VM and start Jupyter Notebook instead, feather gets imported successfully from the notebook.
$conda activate <env_name>
$jupyter-notebook --no-browser --port=8080 &
I see this discussion, but don't see a solution there.
Alternatively, check your path from within your Jupyter notebook vs on the command line. I found that appending the module paths to sys.path solved this exact issue.
All of the ~/anaconda3/envs/[env]/lib/python3.7* paths were missing in my case.
I have found a possible work around to avoid this issue. This is based on this answer.
From the conda environment (e.g. my_env), I can create a new Python 3 kernel (say, python3_custom). Now, this kernel will be associated with all the libraries installed in that conda environment.
$ conda activate my_env
(my_env)$ conda install ipykernel
(my_env)$ ipython kernel install --user --name=python3_custom
(my_env)$ conda deactivate
I come out of my_env or base environment. Then I start JupyterLab from the command prompt:
jupyter lab --no-browser --port=8080 &
Once I open my notebook now, I can select the kernel as python3_custom. Since in the associated conda environment (my_env), feather is already installed, I don't get the error "Module Not Found" any more.