# Why are conda and mamba not fully activating my environment on Cheaha?

**URL:** <https://ask.cyberinfrastructure.org/t/why-are-conda-and-mamba-not-fully-activating-my-environment-on-cheaha/2649>\
**Category:** University of Alabama at Birmingham\
**Tags:** anaconda, conda, mamba\
**Created:** [January 24, 2023, 4:00pm UTC](https://ask.cyberinfrastructure.org/t/why-are-conda-and-mamba-not-fully-activating-my-environment-on-cheaha/2649 "2023-01-24T16:00:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wwarr](https://ask.cyberinfrastructure.org/letter_avatar_proxy/v4/letter/w/3be4f8/32.png) [@wwarr](https://ask.cyberinfrastructure.org/u/wwarr)\
**Post date:** [January 24, 2023, 4:00pm UTC](https://ask.cyberinfrastructure.org/t/why-are-conda-and-mamba-not-fully-activating-my-environment-on-cheaha/2649/1 "2023-01-24T16:00:34Z")

</div>

When I use `conda activate myenv` or `mamba activate myenv`, my environment `myenv` seems to only be partially activate.

My terminal prompt shows the first line below. I expect to see the second line.

```shell
(base) [researcher@login004 ~]$
(myenv) [researcher@login004 ~]$

```

When I use `conda env list` I see the following, in conflict with the previous point.

```shell
myenv * /home/researcher/.conda/envs/myenv
                       # ... other environments omitted
base /share/apps/rc/software/Anaconda3/2022.05

```

When I use `conda list` I see packages from `myenv`, again in conflict with the apparently activated environment as seen from the terminal prompt. When I attempt to use a package in `myenv`, the corresponding package from `base` is used or there is an error message about missing packages.

What is going wrong and what can I do about this?

---

<div class="post-metadata">

**Author:** ![wwarr](https://ask.cyberinfrastructure.org/letter_avatar_proxy/v4/letter/w/3be4f8/32.png) [@wwarr](https://ask.cyberinfrastructure.org/u/wwarr)\
**Post date:** [January 24, 2023, 4:03pm UTC](https://ask.cyberinfrastructure.org/t/why-are-conda-and-mamba-not-fully-activating-my-environment-on-cheaha/2649/2 "2023-01-24T16:03:39Z")

</div>

This issue results from using `conda init` on Cheaha. As a reminder, please do not use `conda init` even if `conda` or `mamba` instruct or recommend its use. Using `conda init` can result in unusual and hard-to-diagnose issues like this one.

Please see [this answer to a similar question](https://ask.cyberinfrastructure.org/t/why-do-i-get-an-error-when-launching-an-open-ondemand-hpc-interactive-session/2496/2) for details on resolving the issue.

---

<div class="post-metadata">

**Author:** ![nucci](https://ask.cyberinfrastructure.org/letter_avatar_proxy/v4/letter/n/f6c823/32.png) [@nucci](https://ask.cyberinfrastructure.org/u/nucci)\
**Post date:** [January 24, 2023, 10:13pm UTC](https://ask.cyberinfrastructure.org/t/why-are-conda-and-mamba-not-fully-activating-my-environment-on-cheaha/2649/3 "2023-01-24T22:13:19Z")

</div>

I use ‘source activate myenv’ rather than 'conda ’ or ‘mamba activate’. Using ‘source activate’ avoids requiring ‘conda init’ and all the problems it entails. This might not be the ideal strategy, but it is one that works for us at our site.

---

<div class="post-metadata">

**Author:** ![wwarr](https://ask.cyberinfrastructure.org/letter_avatar_proxy/v4/letter/w/3be4f8/32.png) [@wwarr](https://ask.cyberinfrastructure.org/u/wwarr)\
**Post date:** [January 25, 2023, 4:09pm UTC](https://ask.cyberinfrastructure.org/t/why-are-conda-and-mamba-not-fully-activating-my-environment-on-cheaha/2649/4 "2023-01-25T16:09:46Z")

</div>

Thanks for the comment, `source activate` definitely does work on our system with Anaconda, and we used to recommend that method. We use `lmod` to manage core software, including Anaconda, and a couple of years ago modified the `lmod` script so that `conda activate` works as expected on our system. The devs did it in a repeatable way so we avoid regression when upgrading. Our researchers are quite happy, we stopped getting tickets about 'conda activate` not working.

---

<div class="post-metadata">

**Author:** ![joseph.f.guzman](https://ask.cyberinfrastructure.org/letter_avatar_proxy/v4/letter/j/4bbf92/32.png) [@joseph.f.guzman](https://ask.cyberinfrastructure.org/u/joseph.f.guzman)\
**Post date:** [January 25, 2023, 5:44pm UTC](https://ask.cyberinfrastructure.org/t/why-are-conda-and-mamba-not-fully-activating-my-environment-on-cheaha/2649/5 "2023-01-25T17:44:27Z")

</div>

I had looked into this a lot at our site. The cause is that, in bash for sure at least, only shell built-in or shell function commands can edit environment variables in the current shell process. The “conda” command is both a shell function and an executable. Without the shell function, “conda activate myenv” is still a valid command, but it does not edit your PATH or PS1, so it’s not actually loading the environment. Without the “conda” function, conda will also give you those suggestions to run “conda init”.

Whenever “conda activate myenv” is not working, this usually means you do not have the “conda” function in your environment. This was a problem for our group until we added the shell functions from /path/to/anaconda/basedir/etc/profile.d/conda.sh to our Lmod modulefile. In Lmod there are a couple ways to source this “conda.sh” file directly, but I found at least in version v8.4 it wasn’t parsing everything correctly.

“source activate myenv” works because you’re using the “source” shell built-in, and do not require the “conda” shell function or its dependent shell functions. You just need the activate/deactivate executables to exist in your PATH.
