Dead kernel error when opening a notebook - jupyter-notebook

I had to reinstall a newer version of Julia because the earlier version got broke. Having installed a newer version of Julia, I upgraded to the newer kernel on Jupyter; unfortunately, when I open an existing Julia notebook, the kernel automatically dies.
Following a suggestion from this link I issued this command
conda remove ipykernel
to resolve the problem; because I don't have sudo rights the following error was thrown:
CondaIOError: Missing write permissions in ...
Is there is a way to resolve this issue without creating a virtual environment?
Following your #xiaodai and #Przemyslaw Szufel suggestions, I'm halted by this error
using IJulia
[ Info: Precompiling IJulia [7073ff75-c697-5162-941a-fcdaad2a7d2a]
ERROR: LoadError: ArgumentError: Package ZMQ [c2297ded-f4af-51ae-bb23-16f91089e4e1] is required but does not seem to be installed:
- Run `Pkg.instantiate()` to install all recorded dependencies.
Stacktrace:
[1] _require(::Base.PkgId) at ./loading.jl:929
[2] require(::Base.PkgId) at ./loading.jl:858
[3] require(::Module, ::Symbol) at ./loading.jl:853
[4] include at ./boot.jl:326 [inlined]
[5] include_relative(::Module, ::String) at ./loading.jl:1038
[6] include(::Module, ::String) at ./sysimg.jl:29
[7] top-level scope at none:2
[8] eval at ./boot.jl:328 [inlined]
[9] eval(::Expr) at ./client.jl:404
[10] top-level scope at ./none:3
in expression starting at /storage/home/julia_depot/packages/IJulia/9ajf8/src/IJulia.jl:36
ERROR: Failed to precompile IJulia [7073ff75-c697-5162-941a-fcdaad2a7d2a] to /storage/home/julia_depot/compiled/v1.1/IJu
lia/nfu7T.ji.
Stacktrace:
[1] error(::String) at ./error.jl:33
[2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1197
[3] _require(::Base.PkgId) at ./loading.jl:960
[4] require(::Base.PkgId) at ./loading.jl:858
[5] require(::Module, ::Symbol) at ./loading.jl:853
I have as suggested by the error message issued
Pkg.instantiate()
Also, I have tried
using ZMQ
ERROR: ArgumentError: Package ZMQ [c2297ded-f4af-51ae-bb23-16f91089e4e1] is required but does not seem to be installed:
- Run `Pkg.instantiate()` to install all recorded dependencies.
Although, ZMQ has been installed.

I have this happen to me often. You can try to follow #Przemyslaw's advice and remove the folders or try this
]update
]build IJulia
using IJulia
notebook()
Typically add builds the IJulia, but I find that sometimes after updating, running build manually can help resolve the dead kernel issue.

Use the Anaconda built-into Julia to start the jupyter notebook. In this way you will not have administrative rights nor configure virtual env to manage your Python installation.
julia> ]
(v1.0) pkg> add IJulia
julia> using IJulia
julia> notebook()
Actually you can also run the Julia Jupyter notebook outside of Julia console!
Windows (note that paths on your system might be different):
C:\> %userprofile%\.julia\packages\Conda\hsaaN\deps\usr\Scripts\jupyter-notebook
Linux (note that paths on your system might be different, this should also work on OSX):
$ ~/.julia/packages/Conda/hsaaN/deps/usr/bin/jupyter notebook

Related

Run a specific version of Julia in Jupyter notebook

I recently installed Julia version 0.7.0 (I need this older version). Prior to that, I had installed Julia 1.6.2, and I can use it in Jupyter notebook. Now, through Julia command line in version 0.7.0, I installed IJulia, and after launching the jupyter notebook through the same command line, I am not able to open notebooks in version 0.7.0. I only see options for 1.6.2.
How can I launch a notebook with version 0.7.0 of Julia?
UPDATE
Now I am able to see Julia 0.7.0 as an option when I open Jupyter notebook, but now the kernel does not connect when I want to use it for this specific version. It works fine for version 1.6.2.
I have tried opening a notebook in two different ways:
From anaconda command line: The notebook launches, but the kernel does not connect. The following error keeps repeating:
ERROR: LoadError: MethodError: no method matching setindex!(::Ptr{Nothing}, ::Ptr{Nothing})
Stacktrace:
[1] start_heartbeat(::ZMQ.Socket) at C:\Users\josh\.julia\packages\IJulia\AQu2H\src\heartbeat.jl:20
[2] init(::Array{String,1}) at C:\Users\josh\.julia\packages\IJulia\AQu2H\src\init.jl:100
[3] top-level scope at none:0
[4] include at .\boot.jl:317 [inlined]
[5] include_relative(::Module, ::String) at .\loading.jl:1038
[6] include(::Module, ::String) at .\sysimg.jl:29
[7] exec_options(::Base.JLOptions) at .\client.jl:239
[8] _start() at .\client.jl:432
in expression starting at C:\Users\josh\.julia\packages\IJulia\AQu2H\src\kernel.jl:24
From Julia command line: I get a message that says Process Exited(1) at the end without opening any notebook.
Try
julia> using Pkg; Pkg.build("IJulia")
within the 0.7 REPL. This should install the Jupyter kernel for Julia 0.7 and make it available as an option.
In case that doesn't work for some reason, you can also try explicitly calling the installkernel function:
julia> installkernel("Julia 0.7")

I have a problem precompile the Flux package in Julia

I am trying to add Flux into my package repository in Julia but I am getting an error.
I typed pkg> add Flux but Julia REPL returns "5 dependencies errored".
And they are:
LLVM
GPUCompiler
CUDA
NNlibCUDA
Flux
To see a full report either run import Pkg; Pkg.precompile() or load the packages
I ran the command precompile and this is what i got.
ERROR: The following 1 direct dependency failed to precompile:
Flux [587475ba-b771-5e3f-ad9e-33799f191a9c]
Failed to precompile Flux [587475ba-b771-5e3f-ad9e-33799f191a9c] to
C:\Users\Kostas\.julia\compiled\v1.6\Flux\jl_3C4D.tmp.
ERROR: LoadError: could not load library "C:\Users\Kostas\.julia\juliaup\julia-
1.6.4+0~x64\bin\LLVM.dll"
The specified module could not be found.
Stacktrace:
[1] dlopen
# .\libdl.jl:114 [inlined]
[2] #dlopen#2
# .\libdl.jl:110 [inlined]
[3] dlopen (repeats 2 times)
# .\libdl.jl:110 [inlined]
[4] loaded_llvm()
# LLVM.API C:\Users\Kostas\.julia\packages\LLVM\shuW4\src\LLVM.jl:49
[5] top-level scope
# C:\Users\Kostas\.julia\packages\LLVM\shuW4\src\LLVM.jl:60
[6] top-level scope (repeats 2 times)
# none:1
Any ideas how can i fix this and use Flux properly?

Julia Can't Test User Packages

I have a Julia package I developed locally, let's call it mypack, and I can't automatically test it with Julia in pkg mode. Running pkg>test mypack gives me the following error:
(v1.3) pkg> test mypack
Updating registry at `~/.julia/environments/v1.3/registries/General`
Updating git-repo `https://github.com/JuliaRegistries/General.git`
Testing mypack
Resolving package versions...
[ Info: No changes
Status `/tmp/jl_m6URie/Manifest.toml`
[4e168b6d] mypack v0.1.0 [`~/Documents/mypack`]
ERROR: LoadError: ArgumentError: Package Test not found in current path:
- Run `import Pkg; Pkg.add("Test")` to install the Test package.
Stacktrace:
[1] require(::Module, ::Symbol) at ./loading.jl:887
[2] include at ./boot.jl:328 [inlined]
[3] include_relative(::Module, ::String) at ./loading.jl:1105
[4] include(::Module, ::String) at ./Base.jl:31
[5] include(::String) at ./client.jl:424
[6] top-level scope at none:6
in expression starting at /home/myname/Documents/mypack/test/runtests.jl:1
ERROR: Package mypack errored during testing
My mypack project has the expected structure where there's a root directory with a Project.toml and Manifest.toml generated using ]generate mypack. /test/runtests.jl is just the line
using Test
This works on two machines that I've tested it on, one of which was using Julia 1.1 and one which was using Julia 1.2. The errors are happening on a new install of Julia 1.3.
I am able to test other packages (such as Statistics just fine, which I did to make sure Test was working). I have a more complicated project which brought this to my attention, but this mypack MWE is also broken.
When you run Pkg.test, Pkg creates a test environment. This environment consists of direct dependencies and test dependencies. Any dependency which is imported by test/runtests.jl needs to be in this test environment.
Because your test/runtests.jl imports the Test standard library, you need to add it as a test dependency. You can add test dependencies using this method: https://julialang.github.io/Pkg.jl/v1/creating-packages/#Test-specific-dependencies-in-Julia-1.0-and-1.1-1.

How to get Pkg in Julia 0.5? ("ERROR: unknown package Pkg")

I need to run a code written in Julia 0.5.
I installed this version on macOS and when I run
using Pkg
It returns the error:
ERROR: ArgumentError: Module Pkg not found in current path.
Run `Pkg.add("Pkg")` to install the Pkg package.
in require(::Symbol) at ./loading.jl:365
in require(::Symbol) at /Applications/Julia-0.5.app/Contents/Resources/julia/lib/julia/sys.dylib:?
When I run
Pkg.add("Pkg")
It returns
INFO: Initializing package repository /Users/henrique/.julia/v0.5
INFO: Cloning METADATA from https://github.com/JuliaLang/METADATA.jl
ERROR: unknown package Pkg
in macro expansion at ./pkg/entry.jl:53 [inlined]
in (::Base.Pkg.Entry.##2#5{String,Base.Pkg.Types.VersionSet})() at ./task.jl:360
in sync_end() at ./task.jl:311
in macro expansion at ./task.jl:327 [inlined]
in add(::String, ::Base.Pkg.Types.VersionSet) at ./pkg/entry.jl:51
in (::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#add,Tuple{String}})() at ./pkg/dir.jl:31
in cd(::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#add,Tuple{String}}, ::String) at ./file.jl:59
in #cd#1(::Array{Any,1}, ::Function, ::Function, ::String, ::Vararg{Any,N}) at ./pkg/dir.jl:31
How to get Pkg in Julia 0.5 then?
That is a very old version of Julia. It is strongly recommended to use a recent version, see the downloads page: https://julialang.org/downloads/. In 0.5 the Pkg module was available by default, so I'm not sure how using Pkg doesn't work. In general, if you're following recent instructions, they're not going to work on such an old version of the language.

PowerModels and JuMP version conflict: Unsatisfiable requirements

I'm new to Julia. I wanted to test out some basic function calls in the PowerModels package with Julia 1.1.0 (it passed the Pkg.test()) so I wrote a few lines according to their tutorial:
using PowerModels
using Ipopt
using JuMP # example didn't have this line
run_ac_opf("case5.m", JuMP.with_optimizer(Ipopt.Optimizer))
I saved it as test1.jl, ran it on REPL with include("test1.jl") and got the following error:
julia> include("test1.jl")
ERROR: LoadError: UndefVarError: with_optimizer not defined
Stacktrace:
[1] include at .\boot.jl:326 [inlined]
[2] include_relative(::Module, ::String) at .\loading.jl:1038
[3] include(::Module, ::String) at .\sysimg.jl:29
[4] include(::String) at .\client.jl:403
[5] top-level scope at none:0
I'm not sure what's the cause for this error since when I tried both deleting the using JuMP and changing to using JuMP.with_optimizer, I still get the UndefVarError.
UPDATE
I tried ] rm JuMP and ] rm PowerModels, and added the latest v0.19.1 JuMP (I tried only removing my v0.18.5 JuMP but it conflicted with my installed PowerModels package. However, now when I try ] add PowerModels, it gives me the following error:
(v1.1) pkg> add PowerModels
Resolving package versions...
ERROR: Unsatisfiable requirements detected for package JuMP [4076af6c]:
JuMP [4076af6c] log:
├─possible versions are: 0.19.1 or uninstalled
├─JuMP [4076af6c] is fixed to version 0.19.1
└─found to have no compatible versions left with PowerModels [c36e90e8]
└─PowerModels [c36e90e8] log:
├─possible versions are: [0.1.0, 0.2.0-0.2.3, 0.3.0-0.3.4, 0.4.0, 0.5.0-0.5.1, 0.6.0-0.6.1, 0.7.0-0.7.2, 0.8.0-0.8.8, 0.9.0-0.9.6] or uninstalled
└─restricted to versions * by an explicit requirement, leaving only versions [0.1.0, 0.2.0-0.2.3, 0.3.0-0.3.4, 0.4.0, 0.5.0-0.5.1, 0.6.0-0.6.1, 0.7.0-0.7.2, 0.8.0-0.8.8, 0.9.0-0.9.6]
This is what ] status gives me:
(v1.1) pkg> status
Status `C:\Users\me\.juliapro\JuliaPro_v1.1.0.1\environments\v1.1\Project.toml`
[c52e3926] Atom v0.8.5
[7073ff75] IJulia v1.18.1
[916415d5] Images v0.18.0
[4076af6c] JuMP v0.19.1 [`C:\Users\me\.julia\dev\JuMP`]
[e5e0dc1b] Juno v0.7.0
[91a5bcdd] Plots v0.24.0
[438e738f] PyCall v1.91.2
[d330b81b] PyPlot v2.8.1+ [`C:\Users\me\.julia\dev\PyPlot`]
Seems like I can only use v0.9.6 PowerModels, but according to its github page the stable release is now v0.10.0. Any suggestions?
SOLVED
JuliaPro was the problem. I installed the standalone Julia and was able to use both JuMP and PowerModels.

Resources