Notebook() does not work

Hello everyone, I have installed julia (on ubuntu 20.04) and want to run it in notebook. For this I used:

Pkg.add("IJulia")
using IJulia
notebook()

But in the end it opens this:

[ Info: running `/usr/bin/snap notebook`
Process(setenv(`/usr/bin/snap notebook`; dir="/home/myname"), ProcessExited(64))

But the browser with the notebook does not open, as promised in the tutorials. Please tell me what am I doing wrong?

Hello egor,

  1. I saw /usr/bin/snap. Did you install Julia via snap (or Ubuntu store)?
    Rather than installing Julia from the store, it is recommended to download, extract, and run Julia binary via the official website. Or you could try a CLI installer like jill.py.

  2. Because IJulia.jl uses PyCall.jl (the package calling Python from Julia), by default it uses the system python (/usr/bin/python ) to install jupyter-notebook packages, which may or may not succeed.
    The most frictionless way I tried is to force Julia to use its own miniconda distribution by setting the environment variable ENV["PYTHON"] = "" and re-run Pkg.build("PyCall") .
    I usually set this line (ENV["PYTHON"] = "") at the start-up file ~/.julia/config/startup.jl to ensure Julia uses its own miniconda each time.

Just my two cents to setup Julia in Linux.

1 Like

Thanks for the answer, installed julia again according to your instructions. I have a question: is it normal that I do not have such a file in the ~/.julia/config/startup.jl directory? That is, I can just create this file and continue to work with it?

Yes, the file is not there by default and you can create it.

For example:

mkdir -p ~/.julia/config

echo 'ENV["PYTHON"] = ""' >> ~/.julia/config/startup.jl
2 Likes

When I start Pkg.build(“PyCall”) it writes that *PyCall (not found in project or manifest). Could it be because PyCall is using the wrong virtualenv?

I forgot to mention :sweat_smile: that Julia packages need to be added explicitly to use them. (Even PyCall.jl is a dependency of IJulia.jl) We can add the package temporarily if you don’t want to clutter the base environment.

You could try the following commands in the Julia REPL.

using Pkg

ENV["PYTHON"] = ""

Pkg.add(["PyCall", "IJulia"])

Pkg.build("PyCall")

Pkg.build("IJulia")

using IJulia
notebook()

# This line removes PyCall from Project.toml (a list of explicit dependencies)
Pkg.remove("PyCall")

When I enter Pkg.build(“PyCall”), an error occurs like this:

Error building `Conda`: 
ERROR: LoadError: IOError: mkdir("/path"; mode=0o777): permission denied (EACCES)
Stacktrace:
 [1] uv_error
   @ ./libuv.jl:97 [inlined]
 [2] mkdir(path::String; mode::UInt16)
   @ Base.Filesystem ./file.jl:179
 [3] mkpath(path::String; mode::UInt16)
   @ Base.Filesystem ./file.jl:230
 [4] mkpath(path::String; mode::UInt16) (repeats 2 times)
   @ Base.Filesystem ./file.jl:228
 [5] mkpath(path::String)
   @ Base.Filesystem ./file.jl:225
 [6] top-level scope
   @ ~/.julia/packages/Conda/sNGum/deps/build.jl:54
 [7] include(fname::String)
   @ Base.MainInclude ./client.jl:444
 [8] top-level scope
   @ none:5

tried running julia with sudo, didn’t help

Not trying to really solve your problem, but if you are not bound specificaly to Jupyter, I would suggest trying Neptune and/or Pluto, which do not have all those error-prone dependencies (and are better, IMO).

1 Like

Using DOS, but after adding IJulia I run jupyter notebook from DOS and it works, although you have to choose to start a Julia kernel rather than a python one. I assume you already have python.

I found Pluto devilish when trying to switch Plots backends. But I think that was due to reactivity. If Neptune has Pluto’s good features, like easy HTML grabbing, without the annoying reactivity, I’ll try it. Does Neptune use PlutoUI, since that’s the handiest part of Pluto?

I don’t know. From what I have used they look similar, except for the reactivity. But I am not a heavy user, so I cannot speak about the details.

The last time I tried, it didn’t have PlutoUI and it probably will never have exactly PlutoUI, since that interface depends on the reactivity.
(see also https://github.com/compleathorseplayer/Neptune.jl/issues/21)

I just found that out. I used PlutoUI. But then I tried binding a variable to a slider. The slider worked but the variable didn’t move. I guess you can’t have everything :blush: Maybe I’ll just try to see why backend switching in Plots seems to make Pluto choke. Or just go back to tried and true Jupyter.

About how to make Jupyter run.
Maybe it would be good to know a bit about the environment you are using.

  • What is the output of
    import Pkg; Pkg.status()
  • Which Julia version are you using?

I myself had often some initial problems to get jupyter to run. Your error looks like something which might be solved in a newer Julia version.

   BenchmarkTools v1.1.4
   IJulia v1.23.2
   Neptune v0.14.0
   Pluto v0.14.7
   PyCall v1.92.3
   PyPlot v2.9.0