Python venv "activate: No such file" in Non-Bash Shells (sh/fish/PowerShell)
venv ships a separate activation script per shell. In CI the default shell is often sh/dash (not bash), where source doesn’t exist - or you sourced activate when the shell needs activate.fish/Activate.ps1.
What this error means
A CI step fails with source: not found, .: activate: No such file or directory, or activation that silently does nothing so later commands use the system Python. It "works" interactively in bash but not in the CI shell.
/bin/sh: 1: source: not found
# or, fish
fish: Unknown command: source ... use '.' instead? - and activate is bash-syntax
# or, PowerShell
. : The term 'activate' is not recognized ...Common causes
CI shell is sh/dash, not bash
source is a bash builtin; POSIX sh/dash only has .. A step that runs source .venv/bin/activate under sh fails immediately.
Wrong activate script for the shell
venv provides activate (bash/zsh), activate.fish, activate.csh, and Activate.ps1. Sourcing the bash one in fish/csh/PowerShell breaks on syntax.
How to fix it
Use the POSIX dot, or pin bash
Under sh/dash use . instead of source, or declare bash as the step shell.
# POSIX-portable
. .venv/bin/activate
# or pin the shell (GitHub Actions)
# - run: source .venv/bin/activate
# shell: bashSource the shell-specific script
# fish
source .venv/bin/activate.fish
# PowerShell
.\.venv\Scripts\Activate.ps1Skip activation entirely
Avoid activation problems by calling the venv interpreter by path, or adding its bin dir to PATH once.
.venv/bin/python -m pytest
# or
echo "$PWD/.venv/bin" >> "$GITHUB_PATH"How to prevent it
- Don’t use
sourcein steps that may run under sh/dash - use.or pinshell: bash. - Match the activate script to the shell (fish/csh/PowerShell variants).
- Prefer calling
.venv/bin/pythonor persisting the venv bin to PATH over activation.