Python conda env not activated in CI
conda activation requires shell initialization that does not carry across CI steps by default. Without it, the job runs the base Python and cannot see packages installed into your named env.
What this error means
Commands fail with ModuleNotFoundError or "command not found" because the conda env was created but never activated in the running shell.
CommandNotFoundError: Your shell has not been properly configured to use
'conda activate'. To initialize your shell, run $ conda init <SHELL_NAME>Common causes
conda not initialized for the step shell
Each step is a fresh shell; without sourcing conda or a login shell, conda activate is unavailable.
Activation that does not persist across steps
Even when activation works in one step, the env is gone in the next unless you re-activate or use a login shell.
How to fix it
Use a login shell with the conda action
setup-miniconda configures a bash -l shell so conda activate works and persists per step.
- uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: myenv
- run: python -c "import numpy"
shell: bash -l {0}Run via conda run if you avoid activation
Execute commands inside the env without activating the shell.
conda run -n myenv python -c "import numpy"How to prevent it
- Use setup-miniconda with a login shell for conda jobs.
- Activate or
conda runin every step that needs the env. - Pin the environment name and verify it before running commands.