【已解决】IJulia的安装使用问题


#1

麻烦大家问个有关IJulia的问题:

一、Julia版本:

julia> versioninfo()
Julia Version 1.0.2
Commit d789231e99 (2018-11-08 20:11 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i5-3337U CPU @ 1.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, ivybridge)

二、Pkg.add("IJulia")运行成功后,using IJulia出错,显示如下:

julia> using IJulia
[ Info: Precompiling IJulia [7073ff75-c697-5162-941a-fcdaad2a7d2a]
ERROR: LoadError: IJulia not properly installed. Please run Pkg.build("IJulia")
Stacktrace:
 [1] error(::String) at .\error.jl:33
 [2] top-level scope at none:0
 [3] include at .\boot.jl:317 [inlined]
 [4] include_relative(::Module, ::String) at .\loading.jl:1044
 [5] include(::Module, ::String) at .\sysimg.jl:29
 [6] top-level scope at none:2
 [7] eval at .\boot.jl:319 [inlined]
 [8] eval(::Expr) at .\client.jl:393
 [9] top-level scope at .\none:3
in expression starting at C:\Users\huoze\.julia\packages\IJulia\DL02A\src\IJulia.jl:45
ERROR: Failed to precompile IJulia [7073ff75-c697-5162-941a-fcdaad2a7d2a] to C:\Users\huoze\.julia\compiled\v1.0\IJulia\nfu7T.ji.
Stacktrace:
 [1] error(::String) at .\error.jl:33
 [2] macro expansion at .\logging.jl:311 [inlined]
 [3] compilecache(::Base.PkgId, ::String) at .\loading.jl:1190
 [4] macro expansion at .\logging.jl:309 [inlined]
 [5] _require(::Base.PkgId) at .\loading.jl:947
 [6] require(::Base.PkgId) at .\loading.jl:858
 [7] macro expansion at .\logging.jl:309 [inlined]
 [8] require(::Module, ::Symbol) at .\loading.jl:840

三、继续运行Pkg.build("IJulia"),报错如下:

julia> Pkg.build("IJulia")
  Building Conda ──→ `C:\Users\huoze\.julia\packages\Conda\uQitS\deps\build.log`
  Building ZMQ ────→ `C:\Users\huoze\.julia\packages\ZMQ\ABGOx\deps\build.log`
  Building MbedTLS → `C:\Users\huoze\.julia\packages\MbedTLS\r1Ufc\deps\build.log`
  Building IJulia ─→ `C:\Users\huoze\.julia\packages\IJulia\DL02A\deps\build.log`
┌ Error: Error building `IJulia`:
│ Solving environment: ...working... done
│
│ # All requested packages already installed.
│
│ Error executing Jupyter command 'kernelspec': [Errno 'jupyter-kernelspec' not found] 2
│ [InstallKernelSpec] Removing existing kernelspec in C:\Users\huoze\AppData\Roaming\jupyter\kernels\julia-1.0
│ [WinError 5] 拒绝访问。: 'C:\\Users\\huoze\\AppData\\Roaming\\jupyter\\kernels\\julia-1.0\\logo-32x32.png'
│ ┌ Warning: Could not execute `jupyter --version`.
│ └ @ Main C:\Users\huoze\.julia\packages\IJulia\DL02A\deps\build.jl:41
│ [ Info: Installing Jupyter via the Conda package.
│ [ Info: Running `conda install -y jupyter` in root environment
│ [ Info: Found Jupyter version 4.4.0: C:\Users\huoze\.julia\conda\3\Scripts\jupyter
│ [ Info: Installing Julia kernelspec julia-1.0
│ ERROR: LoadError: failed process: Process(`'C:\Users\huoze\.julia\conda\3\python.exe' 'C:\Users\huoze\.julia\conda\3\Scripts\jupyter-kernelspec-script.py' install --replace --user 'C:\Users\huoze\AppData\Local\Temp\julia-1.0'`, ProcessExited(1)) [1]
│ Stacktrace:
│  [1] error(::String, ::Base.Process, ::String, ::Int64, ::String) at .\error.jl:42
│  [2] pipeline_error at .\process.jl:705 [inlined]
│  [3] #run#504(::Bool, ::Function, ::Cmd) at .\process.jl:663
│  [4] run at .\process.jl:661 [inlined]
│  [5] #installkernel#4(::String, ::Function, ::String) at C:\Users\huoze\.julia\packages\IJulia\DL02A\deps\kspec.jl:85
│  [6] installkernel(::String) at C:\Users\huoze\.julia\packages\IJulia\DL02A\deps\kspec.jl:36
│  [7] top-level scope at logging.jl:308
│  [8] top-level scope at logging.jl:307
│  [9] top-level scope at C:\Users\huoze\.julia\packages\IJulia\DL02A\deps\build.jl:41
│  [10] include at .\boot.jl:317 [inlined]
│  [11] include_relative(::Module, ::String) at .\loading.jl:1044
│  [12] include(::Module, ::String) at .\sysimg.jl:29
│  [13] include(::String) at .\client.jl:392
│  [14] top-level scope at none:0
│ in expression starting at C:\Users\huoze\.julia\packages\IJulia\DL02A\deps\build.jl:9
└ @ Pkg.Operations C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Pkg\src\Operations.jl:1097

请问这个问题该如何解决呢 :sweat_smile:

顺便我想问一下,Julia版本更新以后,我卸载掉旧版本,安装新版本后,jupyter notebookkernel就没有julia的选项了,我看jupyter官网上说要重新执行Pkg.build("IJulia"),但是还是会报错,和上面显示的问题一样,这是为什么呢 :joy:


#2

管理员权限试试吧


#3

我在管理员权限下试过了,报错是一样的 :disappointed_relieved:


#4

运行Pkg.build("IJulia")后,报错内容中有:

[WinError 5] 拒绝访问。: 'C:\\Users\\huoze\\AppData\\Roaming\\jupyter\\kernels\\julia-1.0\\logo-32x32.png'

只需要把这个路径下的那两个logo.png删除就行了 :joy:,具体原因的话不太清楚