# Install IJulia for JupyterHub (multiple-user Jupyter)

**URL:** <https://discourse.julialang.org/t/install-ijulia-for-jupyterhub-multiple-user-jupyter/7432>\
**Category:** General Usage\
**Created:** [December 1, 2017, 12:01pm UTC](https://discourse.julialang.org/t/install-ijulia-for-jupyterhub-multiple-user-jupyter/7432 "2017-12-01T12:01:19Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [December 1, 2017, 12:01pm UTC](https://discourse.julialang.org/t/install-ijulia-for-jupyterhub-multiple-user-jupyter/7432/1 "2017-12-01T12:01:19Z")

</div>

Hello, I am trying to install a Julia (0.6) kernel for JupyterHub, the multi-user version of Jupyter.  
I already have JupyterHub working with Python3 and R kernels, I just need to add Julia.

I did try (from Julia run as root) `Pkg.add("IJulia")`, but that install the julia kernel only for the root user.  
I then tried to create a symlink (`ln -s /root/.local/share/jupyter/kernels/julia-0.6/ /usr/local/share/jupyter/kernels/julia-0.6`) but that make JupyterHub crash.  
There isn’t an option for multi-user installation like for R kernel `IRkernel::installspec(user = FALSE)` ?

Antonello

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [December 1, 2017, 12:29pm UTC](https://discourse.julialang.org/t/install-ijulia-for-jupyterhub-multiple-user-jupyter/7432/2 "2017-12-01T12:29:59Z")

</div>

I did try the following:

> mkdir /usr/local/share/jupyter/kernels/julia-0.61  
> cp /root/.local/share/jupyter/kernels/julia-0.6/logo-32x32.png /usr/local/share/jupyter/kernels/julia-0.61  
> cp /root/.local/share/jupyter/kernels/julia-0.6/logo-64x64.png /usr/local/share/jupyter/kernels/julia-0.61  
> cp /root/.julia/v0.6/IJulia/src/kernel.jl /usr/local/share/jupyter/kernels/julia-0.61/  
> nano /usr/local/share/jupyter/kernels/julia-0.61/kernel.json (just changed the path of kernel.jl)  
> {  
> “display\_name”: “Julia 0.6.1”,  
> “argv”: [  
> “/usr/lib/julia-0d7248e2ff/bin/julia”,  
> “-i”,  
> “–startup-file=yes”,  
> “–color=yes”,  
> “/usr/local/share/jupyter/kernels/julia-0.61/kernel.jl”,  
> “{connection\_file}”  
> ],  
> “language”: “julia”  
> }  
> systemctl start jupyterhub

Now I can see in jupyterhub the Julia kernel, but it still crashes

---

<div class="post-metadata">

**Author:** ![fabiangans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fabiangans/32/2624_2.png) [@fabiangans](https://discourse.julialang.org/u/fabiangans)\
**Post date:** [December 1, 2017, 1:37pm UTC](https://discourse.julialang.org/t/install-ijulia-for-jupyterhub-multiple-user-jupyter/7432/3 "2017-12-01T13:37:45Z")

</div>

We had similar problems when setting up IJulia for Jupyterhub. The main problem is that you can not yet create a system-wide Julia package directory and the IJulia kernel assumes that the IJulia package is installed and usable. However, you probably can not assume that users have already run `Pkg.init()` and Pkg.add(`IJulia`) when they login to jupyterhub. We saw two possibilities:

1. Use a global package directory, so instead of calling in your kernel file /usr/lib/julia-0d7248e2ff/bin/julia directly rather invoke a shell script that contains something like `export JULIA_PKGDIR=/root/.julia;/usr/lib/julia-0d7248e2ff/bin/julia $*` The disadvantage here would be that users can not install their own packages
2. Invoke a shell script like in (1), but instead of setting `JULIA_PKGDIR` it checks if IJulia is installed in the user package directory and if not it creates a `${USER}/.julia/v0.6` directory if it does not exist and then copy the contents of /root/.julia/v0.6 to the user package directory.

We went for option (2) although it still feels quite uncomfortable. Note that the problem will probably be solved once Pkg3 is there, because it will allow using different package directories at the same time (a few system-wide packages + user packages). To summarize, here is our setup, which can probab ly break in many ways, but it works for us:

content of kernel.json:

```julia
{
  "display_name": "Julia 0.6",
  "argv": [
    "/path_to_script/julia_0.6_bin.sh",
    "-i",
    "--startup-file=yes",
    "--color=yes",
    "/usr/local/share/jupyter/kernels/julia-0.61/kernel.jl",
    "{connection_file}"
  ],
  "language": "julia"
}

```

content of julia\_0.6\_bin.sh

```julia
#!/bin/bash --login

export JULIA_PKGDIR="/home/${USER}/.julia"

# Check if IJulia is already installed by the user
if [! -d "${JULIA_PKGDIR}/v0.6/IJulia"]; then
  mkdir -p "${JULIA_PKGDIR}/v0.6"
  cp -r /root/.julia/v0.6/* "${JULIA_PKGDIR}/v0.6"
fi

julia $*

```

---

<div class="post-metadata">

**Author:** ![vishwesh5](https://avatars.discourse-cdn.com/v4/letter/v/9d8465/32.png) [@vishwesh5](https://discourse.julialang.org/u/vishwesh5)\
**Post date:** [July 26, 2018, 3:55am UTC](https://discourse.julialang.org/t/install-ijulia-for-jupyterhub-multiple-user-jupyter/7432/4 "2018-07-26T03:55:59Z")

</div>

Hi!  
Sorry for replying to an old thread.  
I am also using jupyterhub and am trying to install julia-0.6.4 kernel on it. This is what I did:

1. `sudo su -`
2. I added Julia’s path to `~/.bashrc`: `export PATH="/home/ubuntu/julia-9d11f62bcb/bin:$PATH"`
3. I added `IJulia` package: `Pkg.add("IJulia")`
4. I carried out @sylvaticus steps. I copied all the files form `/root/.local/share/jupyter/kernels/julia-0.6/` to `/usr/local/share/jupyter/kernels/julia-0.6`  
I changed the `kernel.json` file:

```julia
{
  "display_name": "Julia 0.6.4",
  "argv": [
    "/home/ubuntu/julia-9d11f62bcb/bin/julia",
    "-i",
    "--startup-file=yes",
    "--color=yes",
    "/usr/local/share/jupyter/kernels/julia-0.6/kernel.jl",
    "{connection_file}"
  ],
  "language": "julia"
}

```

On running `jupyter-kernelspec list`:  
` julia-0.6 /usr/local/share/jupyter/kernels/julia-0.6`  
5. After this, I carry out the steps mentioned by @fabiangans, I revised my `kernel.json` file:

```julia
{
  "display_name": "Julia 0.6.4",
  "argv": [
    "/usr/local/share/jupyter/kernels/julia-0.6/julia_0.6.4_bin.sh",
    "-i",
    "--startup-file=yes",
    "--color=yes",
    "/usr/local/share/jupyter/kernels/julia-0.6/kernel.jl",
    "{connection_file}"
  ],
  "language": "julia"
}

```

And this is what my `/root/julia_0.6.4_bin.sh` says:

```julia
#!/bin/bash --login

export JULIA_PKGDIR="/home/${USER}/.julia"

# Check if IJulia is already installed by the user
if [! -d "${JULIA_PKGDIR}/v0.6/IJulia"]; then
  mkdir -p "${JULIA_PKGDIR}/v0.6"
  cp -r /home/ubuntu/.julia/v0.6/* "${JULIA_PKGDIR}/v0.6"
fi

julia $*

```

I have added 5 users and when I run `jupyterhub` from `root`, the kernel `Julia-0.6` is displayed in the dropdown list. When I open a file using that kernel, this is what the log says:

```julia
ERROR: LoadError: ZMQ.StateError("Address already in use")
Stacktrace:
 [1] [I 2018-07-26 03:53:50.942 SingleUserNotebookApp log:158] 200 GET /user/vishwesh/api/contents/Untitled.ipynb?content=0&_=1532577109578 (vishwesh@::ffff:103.242.62.49) 1.77ms
bind(::ZMQ.Socket, ::String) at /home/vishwesh/.julia/v0.6/ZMQ/src/ZMQ.jl:288
 [2] init(::Array{String,1}) at /home/vishwesh/.julia/v0.6/IJulia/src/init.jl:99
 [3] include_from_node1(::String) at ./loading.jl:576
 [4] include(::String) at ./sysimg.jl:14
 [5] process_options(::Base.JLOptions) at ./client.jl:305
 [6] _start() at ./client.jl:371
while loading /usr/local/share/jupyter/kernels/julia-0.6/kernel.jl, in expression starting on line 9

```

Can someone please help me out with this?

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [July 30, 2018, 9:35am UTC](https://discourse.julialang.org/t/install-ijulia-for-jupyterhub-multiple-user-jupyter/7432/5 "2018-07-30T09:35:36Z")

</div>

I ended up adding this to `/usr/local/sbin/adduser.local `:

`su $1 -c "julia /usr/bin/initJuliaRepository.jl"`

Where `initJuliaRepository.jl` is just:

```julia
Pkg.update()
Pkg.add("IJulia")

```

In this way, when I create a new user with `adduser MYUSER`, this automatically initialises an user level julia repository and adds `IJulia` to it.

---

<div class="post-metadata">

**Author:** ![vishwesh5](https://avatars.discourse-cdn.com/v4/letter/v/9d8465/32.png) [@vishwesh5](https://discourse.julialang.org/u/vishwesh5)\
**Post date:** [July 30, 2018, 10:44am UTC](https://discourse.julialang.org/t/install-ijulia-for-jupyterhub-multiple-user-jupyter/7432/6 "2018-07-30T10:44:10Z")

</div>

Will the packages built manually or modified or installed in just one installation be also copied directly for the new user in this way?

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [July 31, 2018, 12:44pm UTC](https://discourse.julialang.org/t/install-ijulia-for-jupyterhub-multiple-user-jupyter/7432/7 "2018-07-31T12:44:06Z")

</div>

What I done is simply let each user automatically initialise its own private julia repository and install IJulia on it.  
If you mean system-wide installation, I don’t think this is possible with the current Pkg2, although there are some workarounds and Pkg3 should go on that direction:

> [@System wide Pkg installation](https://discourse.julialang.org/t/system-wide-pkg-installation/1402):
>
> Is there a way to install packages system wide alongside those added by users without duplication? I’d really like to be able to install (and precompile) a selection of commonly used packages in a system wide directory, then have users add only the packages they need without duplication. Whatever I’ve tried so far, Pkg.add (run by the user), resolves to a large tree of dependencies, most or all of which are already installed (system wide). When installing the system packages, I’m setting JULIA…

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [July 31, 2018, 3:08pm UTC](https://discourse.julialang.org/t/install-ijulia-for-jupyterhub-multiple-user-jupyter/7432/8 "2018-07-31T15:08:38Z")

</div>

> [@sylvaticus](#):
>
> If you mean system-wide installation, I don’t think this is possible with the current Pkg2

It is possible, you just need to set up the paths (`LOAD_PATH` and `Base.LOAD_CACHE_PATH`) correctly.

---

<div class="post-metadata">

**Author:** ![legendu](https://avatars.discourse-cdn.com/v4/letter/l/e480ec/32.png) [@legendu](https://discourse.julialang.org/u/legendu)\
**Post date:** [November 3, 2018, 1:49am UTC](https://discourse.julialang.org/t/install-ijulia-for-jupyterhub-multiple-user-jupyter/7432/9 "2018-11-03T01:49:32Z")

</div>

I’ve just started exploring Julia since it has published 1.0. After reading various posts, I’ve figure out a way to setup Julia in JupyterHub at [dclong/jupyterhub-julia](https://hub.docker.com/r/dclong/jupyterhub-julia/). The setup is relative simple.

```julia
FROM dclong/jupyterhub:18.10

RUN apt-get update \
    && apt-get install -y julia \
    && apt-get autoremove -y \
    && apt-get autoclean -y

# install IJulia  
ENV JUPYTER=/usr/local/bin/jupyter
RUN julia -e 'empty!(DEPOT_PATH); push!(DEPOT_PATH, "/usr/share/julia"); using Pkg; Pkg.add("IJulia")' \
    && cp -r /root/.local/share/jupyter/kernels/julia-* /usr/local/share/jupyter/kernels/ \
    && chmod -R +rx /usr/share/julia/ \
    && chmod -R +rx /usr/local/share/jupyter/kernels/julia-*/

```

---

<div class="post-metadata">

**Author:** ![l0calh0st](https://avatars.discourse-cdn.com/v4/letter/l/74df32/32.png) [@l0calh0st](https://discourse.julialang.org/u/l0calh0st)\
**Post date:** [April 3, 2020, 3:46pm UTC](https://discourse.julialang.org/t/install-ijulia-for-jupyterhub-multiple-user-jupyter/7432/10 "2020-04-03T15:46:19Z")

</div>

@stevengj @legendu,  
Hi ,  
I am facing issue in julia kernel for AD user.  
If I am adding a user to host then it work fine but for add user kernel is breaking.  
If you know how to resolve such issue please guide me.

Thanksss…

---

<div class="post-metadata">

**Author:** ![martinelli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/martinelli/32/50610_2.png) [@martinelli](https://discourse.julialang.org/u/martinelli)\
**Post date:** [August 13, 2020, 8:30pm UTC](https://discourse.julialang.org/t/install-ijulia-for-jupyterhub-multiple-user-jupyter/7432/11 "2020-08-13T20:30:31Z")

</div>

I have a working JupyterHub installation, forcing IJulia to install on every user creation. However it’s a bit uncomfortable. Does anyone knows how I can use the system-wide installation in this case? I have both 1.0 and 1.4 versions installed. Probably I’ll update 1.4 to 1.5 soon.  
Thanks!
