Julia Pkg.add inCLI vs Jupyter - julia

Is there any difference if I do Pkg.add("Interact") in the cli window vs in a Jupyter notebook? How much of the cli namespace is available in the notebook?

They are the same. The packages are added to the same directory and available in the REPL, in the Juno IDE, in IJulia, in VSCode, etc.

Related

Confusing Jupyter Notebook packages on Anaconda: jupyter or notebook?

I have been wondering about this for a while and cannot seem to find a reliable source to explain this.
I want to install Jupyter Notebook to my Conda environment, and when I search for it on https://anaconda.org/, there are 2 very popular packages available and both of them can open a working Jupyter Notebook with no problem.
https://anaconda.org/anaconda/jupyter
https://anaconda.org/anaconda/notebook
However, according to the Project Jupyter's official documentation, the pip command to install Jupyter Notebook is:
pip install notebook
And nowhere in the documenation, it mentions anything about this jupyter package.
Question
So what exactly is this jupyter package?
It does not have any license, no description, no references to the Project Jupyter website, and the package just looks unmaintained with version 1.0.0 for a while now.
Yet it has > 200k total downloads and when installed, it is able to open Jupyter Notebook properly.
I find it very confusing and easy to lead to dependencies problem in the future in Conda environment.
It's clear from the Project Jupyter instructions that the canonical package name for installing Jupyter Notebook is notebook. There are parallel jupyter and notebook packages in PyPI as well as the anaconda channel you mention. However, it is clear that notebook is regularly updated (as of writing, notebook on anaconda was last updated on 30 July 2022, jupyter on 22 January 2017!) The jupyter package on PyPI has the description "Jupyter metapackage. Install all the Jupyter components in one go." (However, I tested the jupyter anaconda package and it only runs notebook, not eg Jupyterlab.)
I would guess that the jupyter package is left over from when Project Jupyter was just notebooks, without other projects like Jupyter Lab and Jupyter Hub. Of course in installing one should follow the official instructions, since the older package is not kept up to date. The fact that it has a lot of downloads only shows (as does this question) that python package management and the Jupyter ecosystem are confusing for many...

Can't run Julia in Jupyter notebook?

Has anyone had a problem running julia from a jupyter notebook?
I have looked at how-to pages like this one and this one, which all pretty much recommend the same series of steps:
Open the terminal, launch Julia, and Pkg.add("IJulia").
I follow this step and got the following output
Resolving package versions...
Updating `~/.julia/environments/v1.7/Project.toml`
[7073ff75] + IJulia v1.23.3
Updating `~/.julia/environments/v1.7/Manifest.toml`
[7073ff75] + IJulia v1.23.3
[b85f4697] + SoftGlobalScope v1.1.0
[c2297ded] + ZMQ v1.2.1
[8f1865be] + ZeroMQ_jll v4.3.4+0
[a9144af2] + libsodium_jll v1.0.20+0
Launch a Jupyter session and choose a Julia kernel.
I'm able to launch a Jupyter session. However, when I click new, all my option are Python kernels. I don't see anywhere to launch a Julia kernel.
Has anyone run into a similar problem??
I am running macOS Monterey, version 12.4, Apple M1 Max Chip.
My julia is 1.7.2
Try a different step 2:
julia> using IJulia
julia> notebook()
This should open Jupyter in a new browser/tab window. Do you see the Julia kernel in this window? (In which case you might just have different Jupyter versions installed on your system).
you're probably using a jupyter notebook that didn't come with IJulia, thus, you will have to install a kernel spec (a JSON file) so the jupyter knows where to find Julia kernel.
Try following:
https://julialang.github.io/IJulia.jl/stable/manual/installation/#Installing-IJulia
More specifically,
You can force it to use a specific jupyter installation by setting ENV["JUPYTER"] to the path of the jupyter program before running Pkg.build("IJulia")
That's probably because the Jupyter notebook you have installed doesn't have IJulia installed. You will have to load IJulia to access Jupyter with a Julia kernel to fix that.
julia> using IJulia
julia> notebook()
I had the same problem which was the result of having an older version of Jupyter. I solved it by uninstalling and reinstalling the latest jupyter, then added the R and Julia kernels from thw official R, through R Studio, and Julia sites respectively where each kernel installation did not take more than 2 minutes and all work well.
Good luck
EK

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").

R and Julia Kernels not available in Jupyter notebook

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")

How to install and start the 0.4-pre Julia kernel with IPython notebook?

I installed the 0.4-pre Julia kernel on a mac, which goes into
/Applications/Julia-0.4.0-pre-349a4e1977.app/Contents/Resources/julia/bin/julia
and set the symbolic link to this kernel
ln -s /Applications/Julia-0.4.0-pre-349a4e1977.app/Contents/Resources/julia/bin/julia /usr/local/bin/julia
but in my IPython notebook, aka Jupiter, the 0.3.10 starts up when
ipython notebook --profile=julia
How to include the 0.4-pre kernel option in the IPython notebook?
If you have IPython/Jupyter version 3 or above, then you should start it with
ipython notebook
without the
--profile julia
You need to Pkg.add("IPython") and Pkg.build("IPython") in 0.4 to add the 0.4 kernel spec to Jupyter. This is similar to the instructions for when you update Julia here.
Thanks for the answers. Using the info from #ARM and #David P. Sanders, what eventually worked for me on a mac was:
Run the downloaded julia 0.4-pre in a Terminal: exec '/Applications/Julia-0.4.0-pre-349a4e1977.app/Contents/Resources/julia/bin/julia', which gives me a Julia prompt.
At this Julia prompt run Pkg.add("IJulia"), which creates a ~/.julia/v0.4 directory and installs IJulia and a few other packages in that directory.
quit() from this julia prompt.
Navigate to the directory in the Terminal where your myNotebook.ipynb's are or where you want to create them and run ipython notebook at the Terminal prompt, which should open a webpage on localhost:8888 with that directory's files listed. Click on the file you want edit.

Resources