Bad interaction between IJulia and PythonCall (CondaPkg)?

  • IJulia in global environment
  • A project environment that depends on PythonCall (and not IJulia)

Because the limitation of IJulia, at the beginning of a Jupyter notebook, I have to do:

using Pkg
Pkg.activate(<pkg dir>)

Now, it appears that using PythonCall would fail in the notebook, unless I run:

using CondaPkg
CondaPkg.resolve()

# load PythonCall

Here’s the problem, after doing the above, now this fails:

julia --project=<pkg dir>
using PythonCall

and again, I have to do CondaPkg.resolve() in this REPL, which now makes the Jupyter notebook fail the next time.

So it seems to be some cache invalidation between the two ways of interacting with CondaPkg – is there a solution?

In both cases, the error looks like:

julia> using PythonCall
    CondaPkg Found dependencies: /home/jiling/BjetTLA/CondaPkg.toml
ERROR: InitError: expected package `Measurements [eff96d63]` to exist in the manifest (use `resolve` to populate the manifest)
Stacktrace:
  [1] pkgerror(::String, ::Vararg{String})
    @ Pkg.Types ~/.julia/juliaup/julia-1.11.6+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/src/Types.jl:68
  [2] package_info
    @ ~/.julia/juliaup/julia-1.11.6+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/src/API.jl:56 [inlined]
  [3] #9
    @ ./none:0 [inlined]
  [4] iterate
    @ ./generator.jl:48 [inlined]
  [5] Dict{Base.UUID, Pkg.API.PackageInfo}(kv::Base.Generator{Vector{Pkg.Types.PackageSpec}, Pkg.API.var"#9#10"{Pkg.Types.EnvCache}})
    @ Base ./dict.jl:95
  [6] dict_with_eltype
    @ ./abstractdict.jl:636 [inlined]
  [7] dict_with_eltype
    @ ./abstractdict.jl:643 [inlined]
  [8] Dict
    @ ./dict.jl:117 [inlined]
  [9] dependencies
    @ ~/.julia/juliaup/julia-1.11.6+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/src/API.jl:86 [inlined]
 [10] dependencies()
    @ Pkg.API ~/.julia/juliaup/julia-1.11.6+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/src/API.jl:83
 [11] _resolve_find_dependencies(io::Any, load_path::Any)
    @ CondaPkg ~/.julia/packages/CondaPkg/JnPvc/src/resolve.jl:363
 [12] resolve(; force::Bool, io::IO, interactive::Bool, dry_run::Bool)
    @ CondaPkg ~/.julia/packages/CondaPkg/JnPvc/src/resolve.jl:845
 [13] resolve()
    @ CondaPkg ~/.julia/packages/CondaPkg/JnPvc/src/resolve.jl:764
 [14] envdir()
    @ CondaPkg ~/.julia/packages/CondaPkg/JnPvc/src/env.jl:70
 [15] init_context()
    @ PythonCall.C ~/.julia/packages/PythonCall/IOKTD/src/C/context.jl:63

Can’t you just add IJulia to your project environment, and then install a custom kernel that runs IJulia with --project=... to start it in your project environment?

i guess I personally can but it’s quite convoluted for other users that rely on the environmentally installed IJulia