Cannot see installed R kernel on the list of Jupyter kernels on Codespace - jupyter-irkernel

I am trying to use GitHub Codespace with R + Jupyter Notebook setting. However, the notebooks on the codespace do not locate a correct kernel for R.
Here are the steps I went through:
I created a Codespace for my repo.
I clicked on 'Configure Dev Container' and selected "Jupyter Data Science Notebooks", which is supposed to support Python, R, and Julia.
After rebuild, I installed "R" VS code extension and checked that R codes on .r script run fine.
I executed R on Bash, and then installed packages "languageserver" and "IRkernel". IRkernel was already installed.
Then, I executed IRkernel::installspec().
I checked using jupyter kernelspec list that there is a Jupyter kernel for R:
Jupyter kernel list on Bash
However, I don't see a correct R kernel on Jupyter notebook, but instead there is a kernel named "R" with a path to Python:
Jupyter kernel list on notebook
What should I do to have the correct R kernel show up on Jupyter notebook?

Related

How to install a working Intel Data Science Environment with Graphviz

Recently, I found a need to explore the Intel DAAL MKL for Data Science and was having difficulties finding the proper installations for a working environment in one location. After several days and trial and failures, I was able to reach a final installation process that I think would be beneficial to all the other Data Scientist enthusiast who are looking to get started with their Data Science adventures, utilizing Visual Studio Code or JupyterLab. Posted below are my recommended steps to get a working environment on Windows 10.
1. Download and install the latest version of Anaconda: https://www.anaconda.com/distribution/
2. Download and install the latest Graphviz installer from their Web site: https://graphviz.gitlab.io/download/ (in my case, version graphviz-2.38.msi was active)
a. Install graphviz msi for all users
b. Navigate to Environment Variables: https://t.ly/Gz359
c. Create a new environment path for the Graphviz (need two links to be added): (in my case it was: C:\Program Files (x86)\Graphviz2.38\bin\ and C:\Program Files (x86)\Graphviz2.38\bin\dot.exe
d. Close all command and environment windows
e. Open a new cmd window and test for the existence of Graphviz: c:\Users\MyDrive>dot -v
i. You should get a report of the version and other info (if it fails, check the environment path entry and possibly repair your Graphviz installation)
ii. Ctrl-C to close the report
iii. Close the cmd window
iv. Reboot your PC
3. Navigate to Anaconda Command Prompt as Administrator and remain in the (base) environment:
a. In Windows 10, Search for anaconda and select the anaconda command prompt:
i. Right-Click on it and select to run it as Administrator
b. Navigate to the root of the (base) environment:
i. cd\
c. Get a current list of existing environments:
i. conda env list
d. Remove any unwanted environments:
i. conda env remove -n OldenvironmentName
e. Create new desired environment for Intel Data Science (ids) with the most current Conda libraries, and supported Python version 3.x:
i. conda create -n ids python=3 numpy pandas seaborn matplotlib scikit-learn daal4py jupyterlab -y
f. Activate the new environment:
i. conda activate ids
g. Install Graphviz with pip:
i. pip install graphviz
h. Install python support for Graphviz:
i. conda install pydot python-graphviz -y
i. Check that dot is accessible via cmd prompt:
i. dot -v
j. Ctrl-C to close the report
k. Register the following for intel DataScience enhancements:
i. set USE_DAAL4PY_SKLEARN=YES
ii. python -c "import sklearn"
l. Reboot our PC
When you return to your Desktop, you will be ready to use your new environment for Data Science processes

install %%R cell magic in docker from jupyter docker stack

I tried installing the datascience jupyter docker image (tag 45b8529a6bfc, last update Feb 14, 2019) from docker stacks. My entire dockerfile:
FROM jupyter/datascience-notebook:45b8529a6bfc
USER $NB_UID
When I open a new Jupyter notebook with an R kernel, the notebook works fine. When I try a %%R cell magic in an ipython notebook, it doesn't work:
%%R
3+4
UsageError: Cell magic `%%R` not found.
I wandered around various stackoverflow answers and internet searches, tried installing rpy2 (it was already installed). Didn't work.
Suggestions?
Load the jupyter extension before you try to use it:
%load_ext rpy2.ipython
I tried %load_ext rpy2.ipython as suggested by #lgautier, and got the error message No module named 'simplegeneric'. Once I pip installed simplegeneric, everything works and I don't need the load_ext statement.
Not sure why the dockerfile doesn't install simplegeneric, but there you have it.

Pytorch errors: "received an invalid combination of arguments" in Jupyter Notebook

I'm trying to learn Pytorch, but whenever I seem to try any online tutorial (https://pytorch.org/tutorials/beginner/blitz/tensor_tutorial.html#sphx-glr-beginner-blitz-tensor-tutorial-py), I get errors when trying to run certain functions, but only in Jupyter Notebook.
When running
x = torch.empty(5, 3)
I get an error:
module 'torch' has no attribute 'empty'
Furthermore, when running
x = torch.zeros(5, 3, dtype=torch.long)
I get the error:
module 'torch' has no attribute 'long'
Some other functions work fine like:
x = torch.rand(5, 3)
But generally, most code I try to run seems to run into an error really quickly. I couldn't find any resolution online.
When I go into my docker container and simply run python in the shell, I can run these lines just fine with no errors.
I'm running pytorch in a Docker image that I extended from a fastai image, as it already included things like jupyter notebook and pytorch. I used anaconda to update everything, and committed it to a new image for myself.
I have absolutely no idea what the issue could be. I've tried updating packages through anaconda, pip, aptitude in my docker container, and making sure to commit my changes, but nothing seems to work. I also tried creating a new kernel with python 3.7 as I noticed that my Jupyter Notebook only runs in 3.6.4, and when I run python in the shell it is at 3.7.
I've also tried getting different docker images and extending them with what I need, but all images that I've tried have had errors with anaconda where it gets stuck on "Solving environment" step.
Ok, so the fix for me was to either update pytorch through conda using the following command
conda update pytorch
If it's not installed yet, I've gotten it to work in other environments by simply installing it through conda
conda install pytorch
Kind of stupid that I didn't try this earlier, but I was confused on the difference between conda and pip.

Run R in Jupyter notebook - kernel is dying

I am attempting to run R in Jupyter notebook. I tried almost everything what I have found, but without results. So I tried to reinstall Anaconda (Python 2.7.13, Anaconda 4.3.0, IPython 5.1.0) and R (version 3.3.2) to have the latest versions.
Afterwards, I ran
conda install -c r r-essentials
But If I open Jupyter notebook and create a new file with R kernel, the kernel dies immediately and I get long error, see the full version here. The last line:
WindowsError: [Error 2] The system cannot find the file specified
Any suggestions will be very appreciated.

dockerfile: vim (compiled python), vim-ipython, and ipython notebook

I would like to build a Dockerfile in linux which
1. compiles vim with python
2. installs python stack (such as numpy, scipy, ipython, etc)
3. creates ssl certificate for ipython-notebook, to view the notebooks on host machine
It seemed straightforward enough. But I have run into problems despite a variety of approaches, such as linking separate containers, using anaconda, as well as with a single unified image vs separate layers, or creating a user or running all as a root.
In order to run vim, simply installing to root, does not activate pathogen bundle/vim-ipython. Creating a user allows pathogen bundles (ie nerdtree works) to install, but :IPython throws error.
:IPython failed
^-- failed '' not found .
Ive tried the above with no layers/1 large Dockerfile, and with different layers for the python stack, vim, and the ipython notebook.
Dockerfile
What am I not seeing here ?
what does the ^-- failed '' not found referring to?
Ive tried running the ipython notebook using --no-browser & and then running vim, or using running two shells on the same container... but cant get past this error.
Here is a working Dockerfile for anyone trying to get vim-ipython working in Docker.
issues:
user/shared home needed to for vim, despite runtimepath in .vimrc to pathogen/bundle
%connect_info >> required with containers
I am running in root, not sure why vim required a USER to install packages, but changing to USER would throw errors with CMD
--best

Resources