Using IJulia with existing Jupyter installation outwith Anaconda

I installed Julia today and then tried to connect to my existing Jupyter installation; note that I don’t have, or wish to have Anaconda installed. The IJulia package adds and builds successfully but the ENV is missing and when I try to spin up a notebook or lab using IJulia I am prompted to continue with Conda. When declining I receive a bunch of errors.

I searched for some assistance and there is much reference to setting ENV[“JUPYTER”] to an existing jupyter executable, which I duly did but I’m still prompted to use Conda and I still receive the errors if I decline. Some further searching brought me to the IJulia GitHub repo and the documentation states that ENV should be set prior to adding or building the IJulia package. With this knowledge I did Pkg.rm(“IJulia”) and removed and then re-added the package after setting ENV[“JUPYTER”] = “/usr/local/bin/jupyter”. I try start a notebook using IJulia but I’m still prompted to use Conda and declining still fails.

This leads me to think that either the path to my existing Jupyter installation is incorrect or that because removing and re-adding doesn’t require building iJulia again, the path specified by ENV is ignored.

Any tips would be very gratefully received,

You can launch Jupyter without using the Julia REPL and just create a new Julia notebook via the standard Jupyter interface (IJulia installs the kernel information to the right place regardless of whether or not you use the Conda version of Jupyter).

1 Like

Hi Justin,

I just solved the problem on my own laptop(Mac) after having some troubles.

Just to mention it:
I tried this in a new virtual environment I only initialized for this!
(If you need help setting up a new environment, please tell me.)

I will just tell you exactly what I did after activating the new environment.

Set ENV paths (find the right paths with “where python” in terminal and test them (after declaring) via “run($(ENV["PYTHON"]) --version)” in Julia, analogous with jupyter):

ENV[“PYTHON”]="/path/to/venv/bin/python"
ENV[“JUPYTER”]= “/path/to/venv/bin/jupyter”

Add and build IJulia:

] add IJulia
] build IJulia

(to reinsure) Check path to Jupyter:

using IJulia
IJulia.JUPYTER

Now I updated Julia:

] update

Use IJulia and run notebook:

using IJulia
notebook()

After updating Julia it was the first time I did not get an Conda import request (install Jupyter via Conda, y/n? [y]: ).

I don’t know wether it was the newly created environment or the Julia update that made it work.
Hope this works for you as well.

Thomas

see also, for further inspiration:

I have a similar problem. I want to use the existing jupyter installation instead of downloading via Conda. So, I follow instructions:

ENV[“PYTHON”]=“C:\Python382”
ENV[“JUPYTER”]=“C:\Python382\Scripts\python.exe”

Then,

Pkg.add(“IJulia”)
using IJulia

When I check:

IJulia.JUPYTER
“C:\Users\xxxxx\.julia\conda\3\Scripts\jupyter.exe”

Which is not what I set with ENV[“JUPYTER”] !!
So, when I say:

notebook()
install Jupyter via Conda, y/n? [y]: n
ERROR: C:\Users\xxxxx.julia\conda\3\Scripts\jupyter.exe is not installed, cannot run notebook

Looks like I’m doing something wrong or IJulia insists on downloading and installing its own jupyter (which takes up > 2 GB of space!)

Sorry there was a typo in my last message:
I set it as:
ENV[“PYTHON”]=“C:\Python382”
ENV[“JUPYTER”]=“C:\Python382\Scripts\jupyter.exe"

and NOT
ENV[“PYTHON”]=“C:\Python382”
ENV[“JUPYTER”]=“C:\Python382\Scripts\python.exe”
as I said in my previous posting.

This is triply wrong:

  • IJulia doesn’t care about the PYTHON environment variable — that is only used to configure PyCall.jl (if you want to use your existing Python installation with PyCall).
  • For PyCall, PYTHON should be set to path of python.exe, not a directory.
  • "C:\Python382" won’t work in Julia because the backslash is interpreted as an escape character. You either need to escape the backslash (\\ insteadl of \) or use raw"C:\Python382".

ENV["JUPYTER"]="C:\Python382\Scripts\python.exe"

This is a path of python.exe, not jupyter.exe, which is why the Jupyter build process ends up ignoring it. (Note also the backslash problem.)

Note that you can check Sys.isexecutable(ENV["JUPYTER"]) to make sure that you gave the path of an executable.

Note that you can just launch jupyter notebook on your own — there is no need to use the IJulia.notebook() function at all if you know how to launch your own Jupyter process. Then it won’t matter whether you correctly told IJulia how to find your Jupyter installation.

Well, as I wrote back, python.exe was a typo. It was jupyter.exe ; also I used double backslash, unfortunately the online editor (discourse…) removed the double backslash and made it single. Since julia does not care about the PYTHON env. variable it is irrelevant if I set it or not. So, the problem still remains.

Did you check Sys.isexecutable(ENV["JUPYTER"]) before running build IJulia as I suggested? Did build IJulia print any warning messages in its log?

In any case, as I wrote above, you can always launch Jupyter yourself. (Even without a Jupyter installed, IJulia installs its kernel configuration files where any Jupyter installation will find it.)

Thank you very much - your insight that IJulia kernel will find the Jupyter installation if it is in the system path made it easy. I now have it running. So, no need for another bulky Conda installation. Just make sure the system path has the python and jupyter executable (in my case: c:/Python382 and c:/Python382/Scripts). Again, much appreciated.

That’s not actually what I said — the Jupyter installation only needs to be in the system path if you want to just set ENV["JUPYTER"] = "jupyter.exe"; if you supply the correct absolute path to ENV["JUPYTER"] then the system path should be irrelevant.

Hello,

Maybe this can help.
I solved the problem on Windows 10, Julia 1.5.2 by following these steps:

using Pkg
Pkg.add("Conda")
ENV["CONDA_JL_HOME"] = "C:\\Anaconda3\\Scripts\\jupyter.exe"
Pkg.build("Conda")
Pkg.add("IJulia")
Pkg.build("IJulia") #  in case the precompilation did not take place
IJulia.JUPYTER # send "C:\\Anaconda3\\Scripts\\jupyter.exe"

notebook() # jupyter s'ouvre dans le navigateur

Except, I came across a DEAD Kernel Problem, which I solved by editing the following file :

C:\Users\charl\AppData\Roaming\jupyter\kernels\julia-1.5\kernel.json

Replace :
"--project=@."

with :

"--project=C:\\Users\\charl\\.julia\\environments\\v1.5\\Project.toml"

Don’t forget to adapt all the paths to your setup.

1 Like

This is quite interesting that this solves the problem for you. It would be interesting to start julia manually from the windows command line (cmd.exe) with the option --project=@. after changing the directory to the folder containing the notebooks. Maybe you will see a more helpful error message.

(Some students had also strange issues with IJulia, but I was not able to reproduce the error on my machine).

After cd to notebook directory,

I ran :

julia --project="." -E "println(Base.active_project()) ; using IJulia;notebook(dir=pwd())"

This println() show current notebook directory. Then, search for Projet.toml. Since the file does not exist, IJulia select base env project.toml file (" \\.julia\\environements\\........\Project.toml ").
And jupyter open in current dir and works.

I note like you, that when running notebook() in julia, no server logs appears, even if i set the debug option true.

Hope this help,
cet

OK, thank you for making this tests. I was hoping for some debugging information. I will try to make future tests should I get hold of a machine where this problem is visible.

thank you. this change to the kernel.json worked for me. clicking the “Jupyter notebook” icon produces a notebook wherein the Julia 1.6.0 kernel “lives” and no longer presents the dead kernel error.

1 Like

It just should not be this much work to install the Julia kernel. R takes 1 minute and just works. No one should have to install bloataconda in order to get Julia working.

After removing & reinstalling IJulia 3 times, and getting no kernel in the notebook, in desperation I try a launch from Julia REPL. (Those referenced paths do exist, BTW).

julia> IJulia.notebook()
[ Info: running `'C:\Python310\Scripts' notebook`
ERROR: IOError: could not spawn setenv(`'C:\Python310\Scripts' notebook`; dir="C:\\Users\\micha"): no such file or directory (ENOENT)
Stacktrace:
 [1] _spawn_primitive(file::String, cmd::Cmd, stdio::Vector{Any})
   @ Base .\process.jl:99
 [2] #637
   @ .\process.jl:112 [inlined]
 [3] setup_stdios(f::Base.var"#637#638"{Cmd}, stdios::Vector{Any})
   @ Base .\process.jl:196
 [4] _spawn
   @ .\process.jl:111 [inlined]
 [5] run(::Cmd; wait::Bool)
   @ Base .\process.jl:443
 [6] launch(cmd::Cmd, dir::String, detached::Bool)
   @ IJulia C:\Users\micha\.julia\packages\IJulia\e8kqU\src\jupyter.jl:54
 [7] notebook(; dir::String, detached::Bool)
   @ IJulia C:\Users\micha\.julia\packages\IJulia\e8kqU\src\jupyter.jl:97
 [8] notebook()
   @ IJulia C:\Users\micha\.julia\packages\IJulia\e8kqU\src\jupyter.jl:95
 [9] top-level scope
   @ REPL[6]:1

Where did those wrong paths come from? Why is it running the wrong path for the notebook? I don’t know.

But wait, there’s more. I exit the REPL and launch Jupyter normally and - the Julia kernel is there. I test it in a notebook and it’s working.

I know y’all are going to shake your heads because I’m on Windows, but really - it just shouldn’t be this hard.