The most common Micromamba question is why micromamba activate does not work right after installation. The answer is shell initialization. This guide shows how to set it up for every popular shell, and how to work without it.
Why activation needs a shell hook
Activating an environment changes variables inside your current shell, such as PATH. A normal program cannot change the shell that started it, so Micromamba installs a small shell function, called a hook, that runs inside your shell. micromamba shell init writes this hook into your shell startup file.
If you used the official install script and answered "yes" to shell initialization, this is already done. If you installed manually or with Homebrew, you need to run it yourself.
Step 1: Initialize your shell
Pick the line for your shell. The -r option sets the root prefix where environments live.
# bash (Linux, Git Bash)
micromamba shell init -s bash -r ~/micromamba
# zsh (macOS default)
micromamba shell init -s zsh -r ~/micromamba
# fish
micromamba shell init -s fish -r ~/micromamba
# PowerShell (Windows)
micromamba shell init -s powershell -r $Env:UserProfile\micromamba
Micromamba also supports xonsh, cmd.exe and Nushell. In version 2.0 the root prefix option for shell init was renamed from -p to -r, so older tutorials may show the old flag.
Step 2: Restart or reload the shell
Open a new terminal, or reload the profile in the current one:
source ~/.bashrc # bash
source ~/.zshrc # zsh
On Windows, close and reopen PowerShell.
Step 3: Activate an environment
micromamba create -n web python=3.12 -c conda-forge
micromamba activate web
python --version
Your prompt now starts with (web). To leave the environment, run micromamba deactivate. Running micromamba activate with no name activates the empty base environment.
Activating by path
Environments do not have to live under the root prefix. If you created one with -p, activate it by path:
micromamba create -p ./.venv-conda python=3.11
micromamba activate ./.venv-conda
Working without shell initialization
In CI jobs, Docker builds or locked-down servers you may not want to modify shell files. Micromamba has two alternatives:
micromamba runruns one command inside an environment:micromamba run -n web python app.py.micromamba shellopens a new sub-shell with the environment active:micromamba shell -n web.- A temporary hook for the current session only:
eval "$(micromamba shell hook -s posix)".
Fixing activation problems
| Symptom | Likely cause | Fix |
|---|---|---|
| "Shell not initialized" message | No hook in your profile | Run shell init, then restart |
| Works in one terminal, not another | Different shell (bash vs zsh) | Run shell init for each shell you use |
| Broken after an upgrade | Outdated hook | Run micromamba shell reinit |
| PowerShell blocks the profile script | Execution policy | Set a user-level policy such as RemoteSigned that allows local scripts |
| Wrong environment location | Different root prefix | Check micromamba info and the -r value |
How to undo shell initialization
If you no longer want the hook, run micromamba shell deinit -s bash (or your shell). This removes the block that shell init added. It is also the first step of a full uninstall.
Activation in VS Code and Jupyter
Editors do not need your shell to be activated. In VS Code, open the Python interpreter picker and browse to the environment's interpreter, for example ~/micromamba/envs/web/bin/python on Linux and macOS or envs\web\python.exe on Windows. For Jupyter, install ipykernel into the environment and register it:
micromamba install -n web ipykernel
micromamba run -n web python -m ipykernel install --user --name web
Activation inside shell scripts
A script runs in a new, non-interactive shell where your profile may not be loaded. Two reliable patterns:
# option 1: no activation needed
micromamba run -n web python app.py
# option 2: load the hook, then activate
eval "$(micromamba shell hook -s bash)"
micromamba activate web
python app.py
Option 1 is shorter and is the usual choice for cron jobs, CI steps and Docker CMD lines.
Activating an environment automatically
To activate an environment in every new terminal, add micromamba activate web to the end of your shell profile, after the block that shell init created. Keep this for one main environment only; activating several projects automatically quickly becomes confusing.
Next steps
Now that activation works, learn how to create environments from files and how to delete the ones you no longer need.