我如何在 mamba 环境中使 IJulia 正常工作?

huangapple go评论93阅读模式
英文:

How can I get IJulia working inside a mamba environment?

问题

I am having trouble installing IJulia in Julia 1.9.1 inside a mamba environment. The crux of the issue seems to be the compiler not being able to find MbedTLS even though it is installed:

  1. Looking for: ['mbedtls']
  2. conda-forge/noarch 13.1MB @ 4.4MB/s 3.4s
  3. conda-forge/linux-64 32.7MB @ 4.2MB/s 8.9s
  4. Pinned packages:
  5. - python 3.11.*
  6. Transaction
  7. Prefix: /shares/teacher/users/student/mambaforge/envs/jenv
  8. All requested packages already installed
  1. > Using Pkg
  2. > Pkg.update()
  3. >Pkg.add("IJulia") # this works fine
  4. > Using IJulia # This does not

The error when running the above commands is:

  1. MbedTLS [739be429-bea8-5141-9913-cc70e7f3736d]
  2. Failed to precompile MbedTLS [739be429-bea8-5141-9913-cc70e7f3736d] to "libmbedtls.so".
  3. libmbedx509.so.4: cannot open shared object file: No such file or directory
  4. Stacktrace:
  5. [1] dlopen(s::String, flags::UInt32; throw_error::Bool)
  6. @ Base.Libc.Libdl ./libdl.jl:117
  7. [2] dlopen
  8. @ ./libdl.jl:116 [inlined]
  9. [3] dlopen(s::String)
  10. @ Base.Libc.Libdl ./libdl.jl:116
  11. [4] __init__()
  12. @ MbedTLS_jll ~/mambaforge/envs/jenv/share/julia/stdlib/v1.9/MbedTLS_jll/src/MbedTLS_jll.jl:42
  13. [5] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
  14. @ Base ./loading.jl:1115
  15. [6] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any})
  16. @ Base ./loading.jl:1061
  17. [7] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
  18. @ Base ./loading.jl:1506
  19. [8] _require(pkg::Base.PkgId, env::String)
  20. @ Base ./loading.jl:1783
  21. [9] _require_prelocked(uuidkey::Base.PkgId, env::String)
  22. @ Base ./loading.jl:1660
  23. [10] macro expansion
  24. @ ./loading.jl:1648 [inlined]
  25. [11] macro expansion
  26. @ ./lock.jl:267 [inlined]
  27. [12] require(into::Module, mod::Symbol)
  28. @ Base ./loading.jl:1611
  29. [13] include
  30. @ ./Base.jl:457 [inlined]
  31. [14] 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, UInt128}}, source::Nothing)
  32. @ Base ./loading.jl:2045
  33. [15] top-level scope
  34. @ stdin:3
  35. during initialization of module MbedTLS_jll
  36. in expression starting at /shares/teacher/users/student/mambaforge/envs/jenv/share/julia/packages/MbedTLS/lqmet/src/MbedTLS.jl:1
  37. in expression starting at stdin:3
  38. IJulia [7073ff75-c697-5162-941a-fcdaad2a7d2a]
  39. Failed to precompile IJulia [7073ff75-c697-5162-941a-fcdaad2a7d2a] to "libmbedtls.so".
  40. libmbedx509.so.4: cannot open shared object file: No such file or directory
  41. Stacktrace:
  42. [1] dlopen(s::String, flags::UInt32; throw_error::Bool)
  43. @ Base.Libc.Libdl ./libdl.jl:117
  44. [2] dlopen
  45. @ ./libdl.jl:116 [inlined]
  46. [3] dlopen(s::String)
  47. @ Base.Libc.Libdl ./libdl.jl:116
  48. [4] __init__()
  49. @ MbedTLS_jll ~/mambaforge/envs/jenv/share/julia/stdlib/v1.9/MbedTLS_jll/src/MbedTLS_jll.jl:42
  50. [5] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
  51. @ Base ./loading.jl:1115
  52. [6] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any})
  53. @ Base ./loading.jl:1061
  54. [7] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
  55. @ Base ./loading.jl:1506
  56. [8] _require(pkg::Base.PkgId, env::String)
  57. @ Base ./loading.jl:1783
  58. [9] _require_prelocked(uuidkey::Base.PkgId, env::String)
  59. @ Base ./loading.jl:1660
  60. [10] macro expansion
  61. @ ./loading.jl:1648 [inlined]
  62. [11] macro expansion
  63. @ ./lock.jl:267 [inlined]
  64. [12] require(into::Module, mod::Symbol)
  65. @ Base ./loading.jl:1611
  66. [13] include
  67. @ ./Base.jl:457 [inlined]
  68. [14] 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, UInt128}}, source::String)
  69. @ Base ./loading.jl:2045
  70. [15] top-level scope
  71. @ stdin:3
  72. in expression starting at /shares/teacher/users/student/mambaforge/envs/jenv/share/julia/packages/IJulia/Vo51o/src/hmac.jl:1
  73. in expression starting at /shares/teacher/users/student/mambaforge/envs/jenv/share/julia/packages/IJulia/Vo51o/src/IJulia.jl:1
  74. in expression starting at stdin:3
  75. Stacktrace:
  76. [1] pkgerror(msg::String)
  77. @ Pkg.Types ~/mambaforge/envs/jenv/share/julia/stdlib/v1.9/Pkg/src/Types.jl:69
  78. [2] precompile(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; internal_call::Bool, strict::Bool, warn_loaded::Bool, already_instantiated::Bool, timing
  79. <details>
  80. <summary>英文:</summary>
  81. I am having trouble installing `IJulia` in Julia 1.9.1 inside a mamba environment. The crux of the issue seems to be the compiler not being able to find MbedTLS even though it is installed
  82. ```stdout
  83. Looking for: [&#39;mbedtls&#39;]
  84. conda-forge/noarch 13.1MB @ 4.4MB/s 3.4s
  85. conda-forge/linux-64 32.7MB @ 4.2MB/s 8.9s
  86. Pinned packages:
  87. - python 3.11.*
  88. Transaction
  89. Prefix: /shares/teacher/users/student/mambaforge/envs/jenv
  90. All requested packages already installed
  1. &gt; Using Pkg
  2. &gt; Pkg.update()
  3. &gt;Pkg.add(&quot;IJulia&quot;) # this works fine
  4. &gt; Using IJulia # This does not

The error when running the above commands is:

  1. MbedTLS [739be429-bea8-5141-9913-cc70e7f3736d]
  2. Failed to precompile MbedTLS [739be429-bea8-5141-9913-cc70e7f3736d] to &quot;/shares/teacher/users/student/mambaforge/envs/jenv/share/julia/compiled/v1.9/MbedTLS/jl_g7s41h&quot;.
  3. ERROR: LoadError: InitError: could not load library &quot;libmbedtls.so&quot;
  4. libmbedx509.so.4: cannot open shared object file: No such file or directory
  5. Stacktrace:
  6. [1] dlopen(s::String, flags::UInt32; throw_error::Bool)
  7. @ Base.Libc.Libdl ./libdl.jl:117
  8. [2] dlopen
  9. @ ./libdl.jl:116 [inlined]
  10. [3] dlopen(s::String)
  11. @ Base.Libc.Libdl ./libdl.jl:116
  12. [4] __init__()
  13. @ MbedTLS_jll ~/mambaforge/envs/jenv/share/julia/stdlib/v1.9/MbedTLS_jll/src/MbedTLS_jll.jl:42
  14. [5] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
  15. @ Base ./loading.jl:1115
  16. [6] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any})
  17. @ Base ./loading.jl:1061
  18. [7] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
  19. @ Base ./loading.jl:1506
  20. [8] _require(pkg::Base.PkgId, env::String)
  21. @ Base ./loading.jl:1783
  22. [9] _require_prelocked(uuidkey::Base.PkgId, env::String)
  23. @ Base ./loading.jl:1660
  24. [10] macro expansion
  25. @ ./loading.jl:1648 [inlined]
  26. [11] macro expansion
  27. @ ./lock.jl:267 [inlined]
  28. [12] require(into::Module, mod::Symbol)
  29. @ Base ./loading.jl:1611
  30. [13] include
  31. @ ./Base.jl:457 [inlined]
  32. [14] 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, UInt128}}, source::Nothing)
  33. @ Base ./loading.jl:2045
  34. [15] top-level scope
  35. @ stdin:3
  36. during initialization of module MbedTLS_jll
  37. in expression starting at /shares/teacher/users/student/mambaforge/envs/jenv/share/julia/packages/MbedTLS/lqmet/src/MbedTLS.jl:1
  38. in expression starting at stdin:3
  39. IJulia [7073ff75-c697-5162-941a-fcdaad2a7d2a]
  40. Failed to precompile IJulia [7073ff75-c697-5162-941a-fcdaad2a7d2a] to &quot;/shares/teacher/users/student/mambaforge/envs/jenv/share/julia/compiled/v1.9/IJulia/jl_sxd2YS&quot;.
  41. ERROR: LoadError: InitError: could not load library &quot;libmbedtls.so&quot;
  42. libmbedx509.so.4: cannot open shared object file: No such file or directory
  43. Stacktrace:
  44. [1] dlopen(s::String, flags::UInt32; throw_error::Bool)
  45. @ Base.Libc.Libdl ./libdl.jl:117
  46. [2] dlopen
  47. @ ./libdl.jl:116 [inlined]
  48. [3] dlopen(s::String)
  49. @ Base.Libc.Libdl ./libdl.jl:116
  50. [4] __init__()
  51. @ MbedTLS_jll ~/mambaforge/envs/jenv/share/julia/stdlib/v1.9/MbedTLS_jll/src/MbedTLS_jll.jl:42
  52. [5] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
  53. @ Base ./loading.jl:1115
  54. [6] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any})
  55. @ Base ./loading.jl:1061
  56. [7] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
  57. @ Base ./loading.jl:1506
  58. [8] _require(pkg::Base.PkgId, env::String)
  59. @ Base ./loading.jl:1783
  60. [9] _require_prelocked(uuidkey::Base.PkgId, env::String)
  61. @ Base ./loading.jl:1660
  62. [10] macro expansion
  63. @ ./loading.jl:1648 [inlined]
  64. [11] macro expansion
  65. @ ./lock.jl:267 [inlined]
  66. [12] require(into::Module, mod::Symbol)
  67. @ Base ./loading.jl:1611
  68. [13] include
  69. @ ./Base.jl:457 [inlined]
  70. [14] 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, UInt128}}, source::String)
  71. @ Base ./loading.jl:2045
  72. [15] top-level scope
  73. @ stdin:3
  74. during initialization of module MbedTLS_jll
  75. in expression starting at /shares/teacher/users/student/mambaforge/envs/jenv/share/julia/packages/MbedTLS/lqmet/src/MbedTLS.jl:1
  76. in expression starting at stdin:3
  77. ERROR: LoadError: Failed to precompile MbedTLS [739be429-bea8-5141-9913-cc70e7f3736d] to &quot;/shares/teacher/users/student/mambaforge/envs/jenv/share/julia/compiled/v1.9/MbedTLS/jl_TwrfV9&quot;.
  78. Stacktrace:
  79. [1] error(s::String)
  80. @ Base ./error.jl:35
  81. [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)
  82. @ Base ./loading.jl:2296
  83. [3] compilecache
  84. @ ./loading.jl:2163 [inlined]
  85. [4] _require(pkg::Base.PkgId, env::String)
  86. @ Base ./loading.jl:1805
  87. [5] _require_prelocked(uuidkey::Base.PkgId, env::String)
  88. @ Base ./loading.jl:1660
  89. [6] macro expansion
  90. @ ./loading.jl:1648 [inlined]
  91. [7] macro expansion
  92. @ ./lock.jl:267 [inlined]
  93. [8] require(into::Module, mod::Symbol)
  94. @ Base ./loading.jl:1611
  95. [9] include(mod::Module, _path::String)
  96. @ Base ./Base.jl:457
  97. [10] include(x::String)
  98. @ IJulia ~/mambaforge/envs/jenv/share/julia/packages/IJulia/Vo51o/src/IJulia.jl:33
  99. [11] top-level scope
  100. @ ~/mambaforge/envs/jenv/share/julia/packages/IJulia/Vo51o/src/IJulia.jl:309
  101. [12] include
  102. @ ./Base.jl:457 [inlined]
  103. [13] 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, UInt128}}, source::Nothing)
  104. @ Base ./loading.jl:2045
  105. [14] top-level scope
  106. @ stdin:3
  107. in expression starting at /shares/teacher/users/student/mambaforge/envs/jenv/share/julia/packages/IJulia/Vo51o/src/hmac.jl:1
  108. in expression starting at /shares/teacher/users/student/mambaforge/envs/jenv/share/julia/packages/IJulia/Vo51o/src/IJulia.jl:1
  109. in expression starting at stdin:3
  110. Stacktrace:
  111. [1] pkgerror(msg::String)
  112. @ Pkg.Types ~/mambaforge/envs/jenv/share/julia/stdlib/v1.9/Pkg/src/Types.jl:69
  113. [2] precompile(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; internal_call::Bool, strict::Bool, warn_loaded::Bool, already_instantiated::Bool, timing::Bool, kwargs::Base.Pairs{Symbol, Base.TTY, Tuple{Symbol}, NamedTuple{(:io,), Tuple{Base.TTY}}})
  114. @ Pkg.API ~/mambaforge/envs/jenv/share/julia/stdlib/v1.9/Pkg/src/API.jl:1581
  115. [3] precompile(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.TTY, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
  116. @ Pkg.API ~/mambaforge/envs/jenv/share/julia/stdlib/v1.9/Pkg/src/API.jl:156
  117. [4] precompile(pkgs::Vector{Pkg.Types.PackageSpec})
  118. @ Pkg.API ~/mambaforge/envs/jenv/share/julia/stdlib/v1.9/Pkg/src/API.jl:145
  119. [5] precompile(; name::Nothing, uuid::Nothing, version::Nothing, url::Nothing, rev::Nothing, path::Nothing, mode::Pkg.Types.PackageMode, subdir::Nothing, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
  120. @ Pkg.API ~/mambaforge/envs/jenv/share/julia/stdlib/v1.9/Pkg/src/API.jl:171
  121. [6] precompile()
  122. @ Pkg.API ~/mambaforge/envs/jenv/share/julia/stdlib/v1.9/Pkg/src/API.jl:162
  123. [7] top-level scope
  124. @ REPL[4]:1

I had a read/write error before this and that I was able debug to the png/svg issue!!! There are some older posts that suggested among other things deleting the logo for julia solves read/write issues. As bizarre as that was, I was able to solve it but this MbedTLS issue does not seem to have a whole lot of discussions behind it. If someone is familiar, could you help me get IJulia working?

答案1

得分: 1

我成功找到了一个折中的解决方法,至少允许IJulia进行预编译。首先,我注意到在conda环境的/lib文件夹中,当安装了mbedtls时,正确的.so文件是存在的。然而,看起来Julia并不会在那里查找。我能够通过将环境变量LD_LIBRARY_PATH设置为这个/lib文件夹的绝对路径来解决这个问题。可以通过创建一个小脚本在激活和取消激活环境时自动完成此操作,参见答案。

然而,我仍然面临着编译IJulia的另一个问题,即它找不到文件<conda env>/share/julia/cert.pem。我在<conda env>/ssl文件夹中找到了一个cert.pem文件,并将其复制到了share/julia文件夹中。这似乎起作用了,至少IJulia现在可以无问题地预编译。

英文:

I managed to find a hacky workaround to at least allow IJulia to precompile. First I noticed that in the conda environment /lib folder, the correct .so file exists when mbedtls is installed. However, it looks like Julia doesn't look there. I was able to fix this issue by setting the environment variable LD_LIBRARY_PATH to the absolute path of this /lib folder. This can be done automatically upon activate and deactivate of the environment by making a little script, see this answer.

However, I still faced another issue with compiling IJulia, which was that it couldn't find the file &lt;conda env&gt;/share/julia/cert.pem. I found a cert.pem file in the &lt;conda env&gt;/ssl folder and copied this into the share/julia folder. This seemed to work, at least IJulia now precompiles without issue.

huangapple
  • 本文由 发表于 2023年6月29日 21:51:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/76581689.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定