Body
If Conda commands are not behaving as expected — especially after activating an environment — use this guide to diagnose and fix the issue.
Common Symptoms
You may see one of the following:
-
conda: command not found
-
ModuleNotFoundError: No module named 'conda'
-
conda list or conda install works in base but fails after conda activate
-
conda activate appears to work, but conda install crashes
1. Conda Not Found in a New Shell
Symptom
conda: command not found
Cause
The Anaconda module is not loaded, or Miniforge has not been initialized in the current shell.
Fix (Anaconda module users)
Load the module and initialize:
module load anaconda3/2023.09-0-gcc-14.2.0-tpv4qnt
source $(conda info --base)/etc/profile.d/conda.sh
To load automatically in interactive shells, add to ~/.bashrc:
module load anaconda3/2023.09-0-gcc-14.2.0-tpv4qnt >/dev/null 2>&1 || true
Fix (Miniforge users)
If you installed Miniforge in ~/miniforge3, initialize Conda:
source "$HOME/miniforge3/etc/profile.d/conda.sh"
To make this automatic:
echo 'source "$HOME/miniforge3/etc/profile.d/conda.sh"' >> ~/.bashrc
2. Conda Breaks After conda activate
Symptom
After activating an environment:
conda list
fails with:
ModuleNotFoundError: No module named 'conda'
Cause
In some shells, after activating an environment, the conda command ends up running under the environment’s Python instead of the base Conda Python. When that happens, Conda cannot find its own internal modules and crashes.
This is not an environment corruption issue — it is a shell resolution issue.
Permanent Fix (Anaconda module users)
Add the following to the bottom of your ~/.bashrc:
cat >> ~/.bashrc <<'EOF'
# --- AI.Panther: conda stability fix ---
if command -v module >/dev/null 2>&1; then
module load anaconda3/2023.09-0-gcc-14.2.0-tpv4qnt >/dev/null 2>&1 || true
export AP_CONDA_BASE="/usr/local/spack/opt/spack/linux-ubuntu22.04-cascadelake/gcc-14.2.0/anaconda3-2023.09-0-tpv4qntvngrtc6l34bdz4fey5nxpjpcj"
__conda_setup="$("$AP_CONDA_BASE/bin/python" "$AP_CONDA_BASE/bin/conda" shell.bash hook 2>/dev/null)" && eval "$__conda_setup"
unset __conda_setup
__conda_exe() { "$AP_CONDA_BASE/bin/python" "$AP_CONDA_BASE/bin/conda" "$@"; }
fi
EOF
Then start a new shell:
exec bash -l
After that, conda activate and conda install should work consistently.
3. Incorrect Activation Method
Always activate environments using:
conda activate <env>
Do not use:
source <env>/bin/activate
Using the latter can break Conda’s shell integration and cause unexpected behavior.
Best Practices
-
Keep one environment per project when possible.
-
Load the Anaconda module in every new shell session unless added to ~/.bashrc.
-
Use login nodes only for light installs.
-
Install GPU-enabled packages and heavy builds on compute nodes.
-
Avoid installing conda inside an existing environment.
If you are unsure which Conda installation you are using, run:
type -a conda
which -a python
conda --version