# Getting IJulia to work inside of a mamba venv

**URL:** <https://discourse.julialang.org/t/getting-ijulia-to-work-inside-of-a-mamba-venv/100977>\
**Category:** General Usage\
**Tags:** package, ijulia\
**Created:** [June 29, 2023, 1:47pm UTC](https://discourse.julialang.org/t/getting-ijulia-to-work-inside-of-a-mamba-venv/100977 "2023-06-29T13:47:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon56682678](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@anon56682678](https://discourse.julialang.org/u/anon56682678)\
**Post date:** [June 29, 2023, 1:47pm UTC](https://discourse.julialang.org/t/getting-ijulia-to-work-inside-of-a-mamba-venv/100977/1 "2023-06-29T13:47:19Z")

</div>

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

```plaintext
Looking for: ['mbedtls']

conda-forge/noarch 13.1MB @ 4.4MB/s 3.4s
conda-forge/linux-64 32.7MB @ 4.2MB/s 8.9s

Pinned packages:
  - python 3.11.*

Transaction

  Prefix: /shares/teacher/users/student/mambaforge/envs/jenv

  All requested packages already installed

```

```plaintext
> Using Pkg
> Pkg.update()
>Pkg.add("IJulia") # this works fine
> Using IJulia # This does not

```

The error when running the above commands is:

```julia
MbedTLS [739be429-bea8-5141-9913-cc70e7f3736d]

Failed to precompile MbedTLS [739be429-bea8-5141-9913-cc70e7f3736d] to "/shares/teacher/users/student/mambaforge/envs/jenv/share/julia/compiled/v1.9/MbedTLS/jl_g7s41h".
ERROR: LoadError: InitError: could not load library "libmbedtls.so"
libmbedx509.so.4: cannot open shared object file: No such file or directory
Stacktrace:
  [1] dlopen(s::String, flags::UInt32; throw_error::Bool)
    @ Base.Libc.Libdl ./libdl.jl:117
  [2] dlopen
    @ ./libdl.jl:116 [inlined]
  [3] dlopen(s::String)
    @ Base.Libc.Libdl ./libdl.jl:116
  [4] __init__ ()
    @ MbedTLS_jll ~/mambaforge/envs/jenv/share/julia/stdlib/v1.9/MbedTLS_jll/src/MbedTLS_jll.jl:42
  [5] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1115
  [6] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any})
    @ Base ./loading.jl:1061
  [7] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
    @ Base ./loading.jl:1506
  [8] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:1783
  [9] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1660
 [10] macro expansion
    @ ./loading.jl:1648 [inlined]
 [11] macro expansion
    @ ./lock.jl:267 [inlined]
 [12] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1611
 [13] include
    @ ./Base.jl:457 [inlined]
 [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)
    @ Base ./loading.jl:2045
 [15] top-level scope
    @ stdin:3
during initialization of module MbedTLS_jll
in expression starting at /shares/teacher/users/student/mambaforge/envs/jenv/share/julia/packages/MbedTLS/lqmet/src/MbedTLS.jl:1
in expression starting at stdin:3

IJulia [7073ff75-c697-5162-941a-fcdaad2a7d2a]

Failed to precompile IJulia [7073ff75-c697-5162-941a-fcdaad2a7d2a] to "/shares/teacher/users/student/mambaforge/envs/jenv/share/julia/compiled/v1.9/IJulia/jl_sxd2YS".
ERROR: LoadError: InitError: could not load library "libmbedtls.so"
libmbedx509.so.4: cannot open shared object file: No such file or directory
Stacktrace:
  [1] dlopen(s::String, flags::UInt32; throw_error::Bool)
    @ Base.Libc.Libdl ./libdl.jl:117
  [2] dlopen
    @ ./libdl.jl:116 [inlined]
  [3] dlopen(s::String)
    @ Base.Libc.Libdl ./libdl.jl:116
  [4] __init__ ()
    @ MbedTLS_jll ~/mambaforge/envs/jenv/share/julia/stdlib/v1.9/MbedTLS_jll/src/MbedTLS_jll.jl:42
  [5] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1115
  [6] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any})
    @ Base ./loading.jl:1061
  [7] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
    @ Base ./loading.jl:1506
  [8] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:1783
  [9] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1660
 [10] macro expansion
    @ ./loading.jl:1648 [inlined]
 [11] macro expansion
    @ ./lock.jl:267 [inlined]
 [12] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1611
 [13] include
    @ ./Base.jl:457 [inlined]
 [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)
    @ Base ./loading.jl:2045
 [15] top-level scope
    @ stdin:3
during initialization of module MbedTLS_jll
in expression starting at /shares/teacher/users/student/mambaforge/envs/jenv/share/julia/packages/MbedTLS/lqmet/src/MbedTLS.jl:1
in expression starting at stdin:3
ERROR: LoadError: Failed to precompile MbedTLS [739be429-bea8-5141-9913-cc70e7f3736d] to "/shares/teacher/users/student/mambaforge/envs/jenv/share/julia/compiled/v1.9/MbedTLS/jl_TwrfV9".
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)
    @ Base ./loading.jl:2296
  [3] compilecache
    @ ./loading.jl:2163 [inlined]
  [4] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:1805
  [5] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1660
  [6] macro expansion
    @ ./loading.jl:1648 [inlined]
  [7] macro expansion
    @ ./lock.jl:267 [inlined]
  [8] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1611
  [9] include(mod::Module, _path::String)
    @ Base ./Base.jl:457
 [10] include(x::String)
    @ IJulia ~/mambaforge/envs/jenv/share/julia/packages/IJulia/Vo51o/src/IJulia.jl:33
 [11] top-level scope
    @ ~/mambaforge/envs/jenv/share/julia/packages/IJulia/Vo51o/src/IJulia.jl:309
 [12] include
    @ ./Base.jl:457 [inlined]
 [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)
    @ Base ./loading.jl:2045
 [14] top-level scope
    @ stdin:3
in expression starting at /shares/teacher/users/student/mambaforge/envs/jenv/share/julia/packages/IJulia/Vo51o/src/hmac.jl:1
in expression starting at /shares/teacher/users/student/mambaforge/envs/jenv/share/julia/packages/IJulia/Vo51o/src/IJulia.jl:1
in expression starting at stdin:3

Stacktrace:
 [1] pkgerror(msg::String)
   @ Pkg.Types ~/mambaforge/envs/jenv/share/julia/stdlib/v1.9/Pkg/src/Types.jl:69
 [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}}})
   @ Pkg.API ~/mambaforge/envs/jenv/share/julia/stdlib/v1.9/Pkg/src/API.jl:1581
 [3] precompile(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.TTY, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ Pkg.API ~/mambaforge/envs/jenv/share/julia/stdlib/v1.9/Pkg/src/API.jl:156
 [4] precompile(pkgs::Vector{Pkg.Types.PackageSpec})
   @ Pkg.API ~/mambaforge/envs/jenv/share/julia/stdlib/v1.9/Pkg/src/API.jl:145
 [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{}}})
   @ Pkg.API ~/mambaforge/envs/jenv/share/julia/stdlib/v1.9/Pkg/src/API.jl:171
 [6] precompile()
   @ Pkg.API ~/mambaforge/envs/jenv/share/julia/stdlib/v1.9/Pkg/src/API.jl:162
 [7] top-level scope
   @ 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](https://github.com/JuliaLang/IJulia.jl/issues/845). 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?

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [June 29, 2023, 2:24pm UTC](https://discourse.julialang.org/t/getting-ijulia-to-work-inside-of-a-mamba-venv/100977/2 "2023-06-29T14:24:59Z")

</div>

In general I would recommend _not_ using the `julia` package from conda/mamba. Instead, install the official Julia binary and install packages normally.

You can still install/run Jupyter using the mamba package, and it should see the Julia kernel installed by IJulia on your machine. (You can also configure things like PyCall and PyPlot to use whatever Python you want.)

---

<div class="post-metadata">

**Author:** ![anon56682678](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@anon56682678](https://discourse.julialang.org/u/anon56682678)\
**Post date:** [June 29, 2023, 2:59pm UTC](https://discourse.julialang.org/t/getting-ijulia-to-work-inside-of-a-mamba-venv/100977/3 "2023-06-29T14:59:47Z")

</div>

Interesting.

The issue with that is I am working in a server where I don’t have root privileges. That is not uncommon for many researchers. Students and researchers have to work under supervised setups all the time so it is a bit surprising that Conda/mamba and Julia do not play nice with each other. Oh well!

I strictly avoid installing interpreter/compiler under heavy use in a Dev-cycle in my base env. I will try to go back a few versions and see if that helps. Thanks for chiming in!

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [June 29, 2023, 3:02pm UTC](https://discourse.julialang.org/t/getting-ijulia-to-work-inside-of-a-mamba-venv/100977/4 "2023-06-29T15:02:30Z")

</div>

> [@anon56682678](#):
>
> The issue with that is I am working in a server where I don’t have root privileges.

You can install the official Julia binaries and packages without root privileges; I don’t see how that is relevant here.

---

<div class="post-metadata">

**Author:** ![anon56682678](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@anon56682678](https://discourse.julialang.org/u/anon56682678)\
**Post date:** [June 29, 2023, 5:27pm UTC](https://discourse.julialang.org/t/getting-ijulia-to-work-inside-of-a-mamba-venv/100977/5 "2023-06-29T17:27:09Z")

</div>

Right.

1. Specifically because I tried doing that with JuliaUp and keep running into permission denials for write access when trying to install packages. Access I cannot change,

```julia
Error building `IJulia`:
[ Info: Installing Julia kernelspec in /shares/teacher/users/student/.local/share/jupyter/kernels/julia-1.9
ERROR: LoadError: IOError: stat("/apps/python/latest/bin/jupyter"): permission denied (EACCES)

```

(Write permission error persist after deleting the `.png`s and `.svg`s)

1. Generally because I can’t customize OS level dependencies (read dependencies outside of the compiler) for Jupyter _and_ Julia in the base env? As opposed to a virtual env/path where every dependency on path outside or inside of a language’s ecosystem can be controlled?
