无法在Jupyter Lab及VS Code中运行Julia 1.7.3内核
Julia 1.7.3内核在Jupyter Lab/VS Code无法运行的解决方案
问题现象
- Jupyter Lab运行单元格时报错,核心错误为
Package Parsers does not have SnoopPrecompile in its dependencies,导致IJulia预编译失败 - VS Code中运行无任何反应,无报错输出
报错详情
in expression starting at /home/rohit/.julia/packages/IJulia/AQu2H/src/kernel.jl:1 [I 2022-11-15 10:54:57.314 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (1/5), new random ports [ Info: Precompiling IJulia [7073ff75-c697-5162-941a-fcdaad2a7d2a] ERROR: LoadError: ArgumentError: Package Parsers does not have SnoopPrecompile in its dependencies: - If you have Parsers checked out for development and have added SnoopPrecompile as a dependency but haven't updated your primary environment's manifest file, try `Pkg.resolve()`. - Otherwise you may need to report an issue with Parsers Stacktrace: [1] require(into::Module, mod::Symbol) @ Base ./loading.jl:980 [2] include(mod::Module, _path::String) @ Base ./Base.jl:418 [3] include(x::String) @ Parsers ~/.julia/packages/Parsers/bEa0b/src/Parsers.jl:1 [4] top-level scope @ ~/.julia/packages/Parsers/bEa0b/src/Parsers.jl:393 [5] include @ ./Base.jl:418 [inlined] [6] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String) @ Base ./loading.jl:1318 [7] top-level scope @ none:1 [8] eval @ ./boot.jl:373 [inlined] [9] eval(x::Expr) @ Base.MainInclude ./client.jl:453 [10] top-level scope @ none:1 in expression starting at /home/rohit/.julia/packages/Parsers/bEa0b/src/precompile.jl:1 in expression starting at /home/rohit/.julia/packages/Parsers/bEa0b/src/Parsers.jl:1 ERROR: LoadError: Failed to precompile Parsers [69de0a69-1ddd-5017-9359-2bf0b02dc9f0] to /home/rohit/.julia/compiled/v1.7/Parsers/jl_7qWIcC. Stacktrace: [1] error(s::String) @ Base ./error.jl:33 [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, ignore_loaded_modules::Bool) @ Base ./loading.jl:1466 [3] compilecache(pkg::Base.PkgId, path::String) @ Base ./loading.jl:1410 [4] _require(pkg::Base.PkgId) @ Base ./loading.jl:1120 [5] require(uuidkey::Base.PkgId) @ Base ./loading.jl:1013 [6] require(into::Module, mod::Symbol) @ Base ./loading.jl:997 [7] include(mod::Module, _path::String) @ Base ./Base.jl:418 [8] include(x::String) @ JSON ~/.julia/packages/JSON/NeJ9k/src/JSON.jl:3 [9] top-level scope @ ~/.julia/packages/JSON/NeJ9k/src/JSON.jl:11 [10] include @ ./Base.jl:418 [inlined] [11] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String) @ Base ./loading.jl:1318 [12] top-level scope @ none:1 [13] eval @ ./boot.jl:373 [inlined] [14] eval(x::Expr) @ Base.MainInclude ./client.jl:453 [15] top-level scope @ none:1 in expression starting at /home/rohit/.julia/packages/JSON/NeJ9k/src/Parser.jl:1 in expression starting at /home/rohit/.julia/packages/JSON/NeJ9k/src/JSON.jl:3 ERROR: LoadError: Failed to precompile JSON [682c06a0-de6a-54ab-a142-c8b1cf79cde6] to /home/rohit/.julia/compiled/v1.7/JSON/jl_CxGVlg. Stacktrace: [1] error(s::String) @ Base ./error.jl:33 [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, ignore_loaded_modules::Bool) @ Base ./loading.jl:1466 [3] compilecache(pkg::Base.PkgId, path::String) @ Base ./loading.jl:1410 [4] _require(pkg::Base.PkgId) @ Base ./loading.jl:1120 [5] require(uuidkey::Base.PkgId) @ Base ./loading.jl:1013 [6] require(into::Module, mod::Symbol) @ Base ./loading.jl:997 [7] include @ ./Base.jl:418 [inlined] [8] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String) @ Base ./loading.jl:1318 [9] top-level scope @ none:1 [10] eval @ ./boot.jl:373 [inlined] [11] eval(x::Expr) @ Base.MainInclude ./client.jl:453 [12] top-level scope @ none:1 in expression starting at /home/rohit/.julia/packages/IJulia/AQu2H/src/IJulia.jl:1 ERROR: LoadError: Failed to precompile IJulia [7073ff75-c697-5162-941a-fcdaad2a7d2a] to /home/rohit/.julia/compiled/v1.7/IJulia/jl_f8oPcc. Stacktrace: [1] error(s::String) @ Base ./error.jl:33 [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, ignore_loaded_modules::Bool) @ Base ./loading.jl:1466 [3] compilecache(pkg::Base.PkgId, path::String) @ Base ./loading.jl:1410 [4] _require(pkg::Base.PkgId) @ Base ./loading.jl:1120 [5] require(uuidkey::Base.PkgId) @ Base ./loading.jl:1013 [6] require(into::Module, mod::Symbol)
问题原因
Julia 1.7.3版本不内置SnoopPrecompile包,而当前安装的Parsers包新版本引入了该依赖,导致预编译失败,进而引发IJulia加载错误。VS Code无反应是因为内核启动失败,没有输出日志。
解决方案
方案1:降级Parsers到兼容版本(推荐,保留Julia 1.7.3)
- 打开Julia REPL,按
]进入包管理模式 - 执行以下命令:
add Parsers@2.5.0 resolve precompile build IJulia - 退出包管理模式(按Backspace),重启Jupyter Lab和VS Code
方案2:升级Julia到1.8及以上版本
- 下载并安装Julia 1.8+版本(该版本内置
SnoopPrecompile) - 重新安装IJulia:打开新Julia REPL,进入包管理模式执行
add IJulia,再执行build IJulia - 在Jupyter Lab和VS Code中切换到新的Julia内核
VS Code额外处理
如果执行上述方案后VS Code仍无反应:
- 打开命令面板(Ctrl+Shift+P),执行
Julia: Restart Kernel - 检查VS Code的Julia插件版本,若插件过新,可降级到兼容Julia 1.7的旧版本
内容的提问来源于stack exchange,提问作者rohit deraj
相关产品推荐
相关产品推荐

