Install IJulia notebook on non-networked windows machine? - julia

As a long-time user of Matlab for scientific computing, I am exploring Julia as an alternative but would like to use it within the Jupyter notebook.
I have Julia-0.4.5 installed and functional, and previously downloaded the IJulia notebook installation zip file from github.
However, the installation instruction Pkg.add("IJulia") seems to require network access. My machine is currently not networked.
Anaconda3: installed and functional
IPython Notebook: installed and functional (currently Jupyter only runs the python3 kernel)
Edit:
The Julia documentation gives the following instructions. However, I do not have a another machine to determine the directory from.
Offline Installation of Packages
For machines with no Internet connection, packages may be installed by copying the package root directory (given by Pkg.dir()) from a machine with the same operating system and environment.
Pkg.add() does the following within the package root directory:
Adds the name of the package to REQUIRE.
Downloads the package to
.cache, then copies the package to the package root directory.
Recursively performs step 2 against all the packages listed in the package’s REQUIRE file.
Runs Pkg.build()

Related

renv paths - empty libraries when sharing R project which uses renv package

I'm using the 'renv' R package in an RStudio project to control/lock the package versions used by my script. The libraries sit in the project directory under ... renv\library\R-4.1\x86_64-w64-mingw32. I'm using R version 4.1.3 and renv 0.15.5. When this directory is copied to a colleague's machine (using memory stick) the libraries in the directory mentioned above are blank. I'm assuming these libraries are just pointers to where R saves packages (e.g. "C:/Program Files/R/R-4.1.3/library") and my colleague doesn't have these packages on their machine.
Is there a way to include the packages themselves when sharing the RStudio Project directory?
By default, packages within the renv project directory are symlinked from a global cache location. If you want to ensure packages are instead stored locally in the project library, you can use renv::isolate().
See https://rstudio.github.io/renv/reference/isolate.html for more details.

How do you add Jupyter Notebook kernels for prior versions of Julia?

I am using a Windows machine and trying to have Jupyter Notebook kernels for multiple versions of Julia (0.7.0 and 1.1.1) because package AWS does not support the latest version, but does support 0.7.0.
I had Julia 1.1.1 installed on my computer first and got something similar to the following error when I tried to install package AWS: https://github.com/JuliaLang/Pkg.jl/issues/792
Then I installed Julia 0.7.0 and was able to install AWS in the Julia 0.7.0 terminal with Pkg.add("AWS") with no problems.
In the Julia 0.7.0 terminal, I installed IJulia again with Pkg.add("IJulia") and restarted my Jupyter notebook instance. Now I'd like to use AWS via Jupyter notebook but when I create a new one, only Julia 1.1.1 appears.
I ended up having success by showing which kernels I had using jupyter kernelspec list in terminal, which showed where my other Julia kernel was located.
>>> jupyter kernelspec list
Available Kernels:
julia-1.1 C:\Users\{%USERNAME%}\AppData\Roaming\jupyter\kernels\julia-1.1
python3 C:\ProgramData\Anaconda3\share\jupyter\kernels\python3
I navigated to the file path listed after julia-1.1
Created a julia-0.7 folder in that same directory
Copied over contents from the julia-1.1 folder
Edited the kernel.json file by replacing every instance of julia-1.1.1 with julia-0.7.0
What I ended up having success with seems like a very rudimentary way to solve this problem. I'd like a more elegant way to achieve the same result, similar to when adding multiple kernels for different versions of Python. (Using both Python 2.x and Python 3.x in IPython Notebook)
Please help, thank you!
You (probably) just need to Pkg.build("IJulia") on the second Julia version.
Since Julia 0.7 the package manager uses separate directories for each version of a package, meaning that, from the package managers perspective, the package is already installed, and no downloading or building is performed when you install the same version from a different Julia version. The package manager does not know, however, that IJulia needs to be rebuilt for this new Julia version. You can trigger the build manually by Pkg.build("IJulia").

How can I install the R kernel on an AWS SageMaker notebook instance without internet access?

I am trying to install the R kernel on an AWS SageMaker notebook instance that has no internet access. AWS provides documentation on how to install the R kernel on a notebook instance with internet access here. However, I am trying to install the R kernel on a notebook instance without internet access. Their documentation states that r-essentials must be installed. I've tried downloading/installing the r-essentials tar.bz2 archive from the Anaconda package repository. However, it seems like the r-essentials is simply a metapackage and does not contain the actual packages that are to be installed.
Installing r-essentials using the tar.bz2 archive:
Checking if the R kernel exists in the notebook dropdown:
Is there a workaround for this? The goal is to get the R kernel on the notebook instance. Thanks in advance!
Looks like the r-essential tar file is just meta data of list of R packages that need to be installed. Have you tried building the R package manually[1]?
Another possible solution is going through the list of R packages, upload the tar file and install the ones you need.
[1]https://cran.r-project.org/doc/manuals/R-admin.html#Installing-R-under-Unix_002dalikes

How to redirect R to local repository?

I have rstudio connected with rconnect (both are rstudio products or tools) on Linux OS. When i try to publish shiny application documents (app.R) from rstudio, process or log says:
Installing required R packages with 'packrat::restore()'....
Curl: (6) Couldn't resolve host 'cran.rstudio.com'
I don't want R to go outside (like cran.rstudio.com) to find any R packages since i have R packages already installed.
Question: What is the setup or configuration i can perform to tell rstudio or rconnect to go to specific directory to find packages if require?

specifying R library path for RKernel in Anaconda Jupyter notebook

First let me preface this with the disclaimer that I'm new to R, but a longtime Python power user. Given that I love the conda ecosystem and the Jupyter notebook, I'm trying to set them up as my R development environment as well.
So using the instructions at: https://www.continuum.io/blog/developer/jupyter-and-conda-r I've set up a Jupyter Notbook that using an RKernel that should be hitting the installation of R installed in my Anaconda folder (I would think anyway).
Getting it setup was easy peasy and everything is working great for standard R stuff but my analysis requires some R libraries that are not available in r-essentials channel. No problem, I think I know how to install an R library. I go to "C:\Anaconda\R\bin\x64\Rgui.exe" and install rgdal, dismo, and some other packages. To check my work I looked in C:\Anaconda\R\library and there they are.
But when I run a jupyter notebook from the Anaconda command prompt. And start a new R notebook I get a "Error in library(dismo): there is no package called 'dismo'" Wait a sec, I run a ".libPaths()" from the notebook and it looks like its pointing
You can add .libPaths('path_where_your_packages_are') in a code cell at the beginning of your notebook to tell jupyter where your packages are. For me that was .libPaths('~/R/win-library/3.2') (work-around from discnerd who filed this issue on github).
To find out the path to your packages, just install a random package in R and wait for the location to be printed to the console.
More details (likely specific to my system/installations): When running .libPaths() in R, I got 2 locations: one for which admin rights were required for writing, and one for which admin rights were not required for writing. While packages installed through R land in the location where admin rights are not required, jupyter looks at the location where admin rights are required.
You can find out the path to your library with installed.packages()

Resources