Julia kernel doesn't connect when using jupyter

Hi all,

I’m doing my darndest to try and use Julia with jupyter as ssh’ing through an iPad is all I have access to. I have finally been able to install Julia and IJulia without precompile errors on the host computer in spite of Julia’s best efforts. But now, when I try to run anything in a notebook, the julia kernel never connects. This is in Julia 1.7.3

This is my install procedure:

  • conda create -n jul
  • conda activate jul
  • conda install jupyterlab julia

then in julia:

  • ]add IJulia

I’ve experimented with Pluto, which I can get working and has the ability to port forward, but I can’t run the Julia tutorials on it so that’s a nonstarter. I would appreciate any help anyone can give.

Just tried another thing.
In a fresh environment,

$ wget https://julialang-s3.julialang.org/bin/linux/x64/1.8/julia-1.8.0-linux-x86_64.tar.gz
$ tar -xf julia-1.8.0-linux-x86_64.tar.gz
$ julia-1.8.0/bin/julia
julia> using Pkg
julia> Pkg.add("IJulia")
julia> using IJulia
julia> notebook(detached=true)
julia> run(`$(IJulia.find_jupyter_subcommand("")[1]) notebook list`)

that last line would return a link with a token for me to paste into my browser. All the steps above run fine. I’m even able to start jupyter and get into it. But as soon as I try to open a notebook and connect to a kernel, the kernel fails to connect and gives me an error describing as such, same error I’ve received every time.

Is there any reason not to let IJulia have a private Python+Jupyter installation as described in the manual?

If conda is not working, try using juliaup to install Julia. Installing julia via conda is not officially supported.

If you insist on using conda, try this:

conda create -n juliaup -c conda-forge juliaup
conda activate juliaup

or just download Julia from Download Julia .

The conda-forge version is nice when it works and you have other packages you want to work with in the environment, but if it’s giving you trouble my first recommendation is to see if directly downloading julia from julialang.org will work.

If you can find any logs, output, or anything else giving an error, please share that with us here.

1 Like

Yes, this is also one of the installation procedures I’ve tried with the same results.

Does it fail explicitly, or does it just keep trying? Is there any output at the console you’re running the Jupyter command from?

If you’ve not tried it already, try a ]build IJulia and see if that reports any errors. Also, I’ve found that installing IJulia in anything other than the base environment @v1.7 can cause issues, so make sure you have it in that environment.

Running jupyter-kernelspec list should give you a list of kernel names and directories. In the directory corresponding to the Julia entry, there will be a kernel.json file. Please paste the contents of that file here.

conda create -n juliaup -c conda-forge juliaup
conda activate juliaup

This ended up doing the trick. After so many weeks of trying, thank you for your help!

Turns out this didn’t fix the problem. It worked once and now it won’t work anymore. I have no idea how something like that can happen.

It fails explicitly. Both Conda and IJulia build without any errors.

This is the output of jupyter-kernelspec list:

Available kernels:
  julia-1.8    /home/aaportel/.local/share/jupyter/kernels/julia-1.8
  python3      /home/aaportel/.julia/conda/3/share/jupyter/kernels/python3

and here is the contents of the kernel file:

~$ cat /home/aaportel/.local/share/jupyter/kernels/julia-1.8/kernel.json 
  "display_name": "Julia 1.8.0",
  "argv": [
  "language": "julia",
  "env": {},
  "interrupt_mode": "signal"

The errors I get when the kernel fails are something like:

ERROR: LoadError: Failed to precompile IJulia
ERROR: LoadError: Failed to precompile Conda

So far I’ve tried Julia 1.6, 1.7 and 1.8. I’ve tried within a conda environment, and by downloading Julia on its own, tried installing jupyter internally through Conda.add as well as independently with conda in the same conda environment, I’ve tried setting ENV["JUPYTER"]to the path of jupyter in that environment. I’ve tried multiple host computers, all running some version of x86 linux. I’ve reinstalled conda multiple times and cleaned all my environments, I’ve reinstalled Julia, cleaning .cache, .julia, .local, etc. I’m becoming increasingly frustrated by how difficult it has been to get into this language.

We need a full stack trace to understand what is happening. It’s likely that your conda Python configuration is interfering with the Python environment that Julia setup for itself.

Use conda deactivate until you have a normal prompt without “(base)” or any other environment in the prefix.

Also considering moving or removing your current ~/.julia to start fresh.

Then do the following. Notice we are not explicitly installing Jupyter since installing IJulia.jl does that for us.

ENV["PYTHON"] = ""
using Pkg
pkg"add PyCall"
pkg"build PyCall"
pkg"add IJulia"
pkg"build IJulia"

Running julia /home/aaportel/.julia/packages/IJulia/AQu2H/src/kernel.jl may give some initial hints. Please copy the entire output to here. We can hopefully figure iut what is preventing IJulia from precompiling.

What we are trying to do is to let julia setup it’s own conda environment within ~/.julia/conda This way when you install IJulia it will install exactly the Python packages it needs to function, no more and no less.

My recommedation is to use Julia 1.7 at the moment, simply because we just released 1.8. 1.8 should work but we are just starting to widely deploy it.

1 Like

Alright. I finally got it to consistently work by downloading 1.7.3 directly from the website, hosting on a different computer, making sure to remove .julia, making sure not to be in any conda environment.
My exact commands are:

$ wget https://julialang-s3.julialang.org/bin/linux/x64/1.7/julia-1.7.3-linux-x86_64.tar.gz
$ tar -xf julia-1.7.3-linux-x86_64.tar.gz
$ julia-1.7.3/bin/julia
julia> ENV["PYTHON"] = ""
julia> using Pkg
julia> pkg"add PyCall"
julia> pkg"build PyCall"
julia> pkg"add IJulia"
julia> pkg"build IJulia"
julia> using IJulia
julia> jupyterlab(detached=true)
julia> run(`$(IJulia.find_jupyter_subcommand("")[1]) lab list`)

and pasting the url returned by that last line.

I should note that none of this worked on 1.8, regardless of whether I was in a conda environment or not. Now on to the next roadblock…