# CondaPkg - acitvate environment

**URL:** <https://discourse.julialang.org/t/condapkg-acitvate-environment/107341>\
**Category:** General Usage\
**Tags:** question, package, condapkg\
**Created:** [December 8, 2023, 6:20pm UTC](https://discourse.julialang.org/t/condapkg-acitvate-environment/107341 "2023-12-08T18:20:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [December 8, 2023, 6:20pm UTC](https://discourse.julialang.org/t/condapkg-acitvate-environment/107341/1 "2023-12-08T18:20:01Z")

</div>

I am using CondaPkg and installed two Python packages. After installation I get the message:

```julia
To activate this environment, use:

    micromamba activate /home/ufechner/repos/Tethers.jl/.CondaPkg/env

```

But that does not work, if I try it I get the error:

```julia
micromamba: command not found

```

This works:

```julia
using CondaPkg
CondaPkg.withenv() do
    run(`python src/Tether_01.py`)
end

```

Is it possible to activate this conda environment and run a python script in it WITHOUT starting Julia first?

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [December 8, 2023, 6:40pm UTC](https://discourse.julialang.org/t/condapkg-acitvate-environment/107341/2 "2023-12-08T18:40:00Z")

</div>

That’s likely an error from `micromamba` itself, and you do have it, just not in your path.

CondaPkg.jl depends on it i.e. MicroMamba.jl depending on which likely provides it:

> <https://github.com/JuliaBinaryWrappers/micromamba_jll.jl/blob/main/src/wrappers/x86_64-linux-gnu.jl>

Here might be a clue how to use it/where it’s stored:  
[https://github.com/search?q=repo%3AJuliaPy%2FMicroMamba.jl](https://github.com/search?q=repo%3AJuliaPy%2FMicroMamba.jl) micromamba&type=code

micromamba is an implementation detail, a clone of conda program, should be invisible detail I think, so I’m not sure why you’re getting the error. Maybe it shouldn’t happen?

---

<div class="post-metadata">

**Author:** ![mihalybaci](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mihalybaci/32/13528_2.png) [@mihalybaci](https://discourse.julialang.org/u/mihalybaci)\
**Post date:** [December 8, 2023, 6:46pm UTC](https://discourse.julialang.org/t/condapkg-acitvate-environment/107341/3 "2023-12-08T18:46:23Z")

</div>

As @Palli said, you must have it installed, so the simplest solution (workaround) is to provide the full file path to where ever `micromamba` is stored, which is going to be in `~/.julia` somewhere. It looks like you’re on Linux, so maybe do a `locate` or `find`?

One thing I like to do with my conda envs is add an alias so I don’t have to type `conda activate` all the time. So you could do something similar when you find the binary. Just add some version of this to your `.bashrc` file

```julia
alias my_env='micromamba activate /path/to/micromamba'

```

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [December 8, 2023, 6:48pm UTC](https://discourse.julialang.org/t/condapkg-acitvate-environment/107341/4 "2023-12-08T18:48:53Z")

</div>

MicroMamba.jl depends on micromamba\_jll

[https://juliahub.com/ui/Packages/JuliaBinaryWrappers/micromamba\_jll](https://juliahub.com/ui/Packages/JuliaBinaryWrappers/micromamba_jll)

The JLL should have a Cmd to run micromamba.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [December 8, 2023, 7:06pm UTC](https://discourse.julialang.org/t/condapkg-acitvate-environment/107341/5 "2023-12-08T19:06:51Z")

</div>

OK, I did: `locate micromamba` and found the path.  
I then created a link:

```julia
cd .local/bin
ln -s /home/ufechner/.julia/artifacts/87052ac9aec71548f804b30280151288cb1ed40e/bin/micromamba

```

Now I can run micromamba, and can activate my environment, but there are still issues when using ipython3 . Well I guess I need to read some more of the micromamba documentation.

---

<div class="post-metadata">

**Author:** ![cjdoris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cjdoris/32/213133_2.png) [@cjdoris](https://discourse.julialang.org/u/cjdoris)\
**Post date:** [December 8, 2023, 8:03pm UTC](https://discourse.julialang.org/t/condapkg-acitvate-environment/107341/6 "2023-12-08T20:03:14Z")

</div>

You can get the path to micromamba with `MicroMamba.executable()`. Micromamba is totally self contained so you can copy/link this to somewhere in your PATH.

Though for interactive usage I’d probably recommend installing Mamba instead via the MiniForge distribution: [GitHub - conda-forge/miniforge: A conda-forge distribution.](https://github.com/conda-forge/miniforge). Conda/Mamba/MicroMamba environments are all the same so you can mix and match tools.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [December 11, 2023, 9:31am UTC](https://discourse.julialang.org/t/condapkg-acitvate-environment/107341/7 "2023-12-11T09:31:30Z")

</div>

Summary:  
To use the Python environment that you have installed with CondaPkg the following  
steps are needed:

1. find the path to the micromamba exectable:

```julia
using CondaPkg
CondaPkg.MicroMamba.executable()

```

1. create a link in ./local/bin

```julia
cd .local/bin
ln -s <PATH>

```

1. initalize the shell

```julia
micromamba shell init --shell bash --root-prefix=~/micromamba

```

1. activate the environment

```julia
micromamba activate /home/ufechner/repos/Tethers.jl/.CondaPkg/env

```

I used CondPkg to add ipython:

```julia
using CondaPkg
]
conda add ipython

```

I can run now ipython and interactively debug Python scripts. In VSCode I activated the  
interpreter `.CondaPkg/env/bin/python`, so syntax highlighting etc works also fine.
